Mercurial > hg > octave-lyh > gnulib-hg
changeset 10180:9f98a7fc375c
Fix bug with setuid modes in Solaris 10+ code.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 08 Jun 2008 16:33:02 +0200 |
parents | 90f51b86b088 |
children | 5282ccc922b9 |
files | ChangeLog lib/set-mode-acl.c |
diffstat | 2 files changed, 24 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-08 Bruno Haible <bruno@clisp.org> + + Fix bug with setuid modes in Solaris 10+ code. + * lib/set-mode-acl.c (qset_acl): Call chmod_or_fchmod when acl_set + succeeded, when the mode contains some special bits. + 2008-06-08 Bruno Haible <bruno@clisp.org> Add support for Solaris 7..10 ACLs.
--- a/lib/set-mode-acl.c +++ b/lib/set-mode-acl.c @@ -206,6 +206,8 @@ acl_t *aclp; char acl_text[] = "user::---,group::---,mask:---,other:---"; + int ret; + int saved_errno; if (mode & S_IRUSR) acl_text[ 6] = 'r'; if (mode & S_IWUSR) acl_text[ 7] = 'w'; @@ -222,19 +224,25 @@ errno = ENOMEM; return -1; } - else + + ret = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp)); + saved_errno = errno; + acl_free (aclp); + if (ret < 0) { - int ret = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp)); - int saved_errno = errno; - acl_free (aclp); - if (ret == 0 || saved_errno != ENOSYS) - { - errno = saved_errno; - return ret; - } + if (saved_errno == ENOSYS) + return chmod_or_fchmod (name, desc, mode); + errno = saved_errno; + return -1; } - return chmod_or_fchmod (name, desc, mode); + if (mode & (S_ISUID | S_ISGID | S_ISVTX)) + { + /* We did not call chmod so far, so the special bits have not yet + been set. */ + return chmod_or_fchmod (name, desc, mode); + } + return 0; # else /* Solaris, Cygwin, general case */