Макрос %setup файла RPM Spec, если вы не знаете корневого имени?

Уловка, которую вы можете использовать :удалить разрешение на чтение для каталога, который вы хотите защитить. Это предотвращает явное или неявное перечисление содержимого каталога, что обязательно выполняется любой командой, которой вы не предоставляете определенные дочерние файлы или каталоги. Когда вы указываете имена дочерних элементов, вам нужны только права доступа к каталогу (и executeфлаги ), чтобы вы могли получить доступ ко всему ниже защищенного каталога.

Быстрая демонстрация:

# Create the directory, remove its 'read' flag
**$ mkdir protected && chmod -r protected && ls -ald protected
d-wx--x--x 2 me me 4096 Dec  7 21:58 protected

# You cannot list contents since you cannot read it
**$ ls protected
ls: cannot open directory 'protected': Permission denied

# You can create files in it since you have write permission
**$ touch protected/{1..3}

# You can list specific directories entries
**$ ls -al protected/1
-rw-r--r-- 1 me me 0 Dec  7 21:59 protected/1

# You can also create subdirectories
**$ mkdir protected/subdir

#... and create files in them
**$ touch protected/subdir/{1..3}

#... do wilcard listing of these subdirectories
**$ ls -al protected/subdir
total 8
drwxr-xr-x 2 me me 4096 Dec  7 21:59.
d-wx--x--x 3 me me 4096 Dec  7 21:59..
-rw-r--r-- 1 me me    0 Dec  7 21:59 1
-rw-r--r-- 1 me me    0 Dec  7 21:59 2
-rw-r--r-- 1 me me    0 Dec  7 21:59 3

# You can erase files, along as you specify them explicitly
**$ rm protected/{1..3}

# You cannot do a blanket erase, since it would require reading the directory
**$ rm -rf protected
rm: cannot remove 'protected': Permission denied

#... but that works on its subdirectories
**$ rm -rf protected/subdir

# You can still remove the directory once it is empty
**$ rmdir protected

Но я сомневаюсь, что это решение будет работать в домашнем каталоге, поскольку, вероятно, есть много утилит, которые предполагают права на чтение (вашего проводника, например ).

1
02.04.2020, 11:21
1 ответ

вы можете просто использовать:

%prep
%setup -q -c

%install
cd myproject-*
# continue installation here

опция -c:

%setup expects the archive to create its own top-level directory. If this isn't the case, you'll need to use the -c option.

изhttp://ftp.rpm.org/max-rpm/s1-rpm-inside-macros.html

2
28.04.2021, 23:18

Теги

Похожие вопросы