setgid: chmod g + s, g-x для исполняемого файла

Взгляните на опцию lftp mirror:

mirror [OPTS] [source [target]]

 Зеркалирование указанного исходного каталога в локальный целевой каталог. Если целевой каталог заканчивается
 косой чертой (кроме корня), имя базы источника добавляется к имени целевого каталога.
 Источник и/или цель могут быть URL-адресами, указывающими на каталоги.

Дополнительные подробности см. в http://lftp.yar.ru/lftp-man.html.

EDIT

Из руководства:

lftp - это программа передачи файлов, которая позволяет использовать сложные FTP, HTTP и другие соединения с другими хостами. Если указан сайт, то lftp подключится к этому сайту, иначе соединение должно быть установлено с помощью команды open.

 lftp может работать с несколькими методами доступа к файлам - FTP, FTPS, HTTP, HTTPS, HFTP, FISH, SFTP и
 файл (HTTPS и FTPS доступны только в том случае, если lftp скомпилирован с GNU TLS или OpenSSL).
 библиотекой).

lftp можно использовать для получения файлов по HTTP. Попробуйте:

lftp -e "mirror -c" http://url

4
24.02.2018, 23:38
2 ответа

Como ha editado su pregunta para incluir esto:

Mi pregunta :¿por qué se ignora el capital S sgid para los ejecutables?

No está siendo ignorado. Sen su caso significa que el grupo no puede ejecutar el archivo y, por lo tanto, es benigno. Si desea que el archivo ejecutable se ejecute con los permisos del grupo, debe ser ejecutable por el grupo. Quitaste eso con g-x, por lo que obtienes S. Se ejecutará con permisos de quien lo ejecute y no con permisos del grupo.

0
27.01.2020, 20:57

Muy bien, no me ayudó mucho la única respuesta que me dijo a RTFM. Después de investigar durante unas horas, encontré estas líneas en el kernel de Linux actual.

https://github.com/torvalds/linux/blob/e816c201aed5232171f8eb80b5d46ae6516683b9/fs/exec.c

/* Be careful if suid/sgid is set */
inode_lock(inode);

/* reload atomically mode/uid/gid now that lock held */
mode = inode->i_mode;
uid = inode->i_uid;
gid = inode->i_gid;
inode_unlock(inode);

/* We ignore suid/sgid if there are no mappings for them in the ns */
if (!kuid_has_mapping(bprm->cred->user_ns, uid) ||
     !kgid_has_mapping(bprm->cred->user_ns, gid))
    return;

if (mode & S_ISUID) {
    bprm->per_clear |= PER_CLEAR_ON_SETID;
    bprm->cred->euid = uid;
}

if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
    bprm->per_clear |= PER_CLEAR_ON_SETID;
    bprm->cred->egid = gid;
}

Claramente, esto es intencional.

Esto se remonta a la carga original en github en mayo de 2005:

https://github.com/torvalds/linux/blob/3677209239ed71d2654e73eecfab1dbec2af11a9/fs/exec.c

bprm->e_uid = current->euid;
bprm->e_gid = current->egid;

if(!(bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)) {
    /* Set-uid? */
    if (mode & S_ISUID) {
        current->personality &= ~PER_CLEAR_ON_SETID;
        bprm->e_uid = inode->i_uid;
    }

    /* Set-gid? */
    /*
     * If setgid is set but no group execute bit then this
     * is a candidate for mandatory locking, not a setgid
     * executable.
     */
    if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
        current->personality &= ~PER_CLEAR_ON_SETID;
        bprm->e_gid = inode->i_gid;
    }
}

Buscar en Google el comentario conduce a:

https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt

  1. Marking a file for mandatory locking
    A file is marked as a candidate for mandatory locking by setting the group-id bit in its file mode but removing the group-execute bit. This is an otherwise meaningless combination, and was chosen by the System V implementors so as not to break existing user programs.
    Note that the group-id bit is usually automatically cleared by the kernel when a setgid file is written to. This is a security measure. The kernel has been modified to recognize the special case of a mandatory lock candidate and to refrain from clearing this bit. Similarly the kernel has been modified not to run mandatory lock candidates with setgid privileges.

Así que la respuesta parece ser "porque fue elegido para significar otra cosa. "

3
27.01.2020, 20:57

Теги

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