-inline int stickydirmode(name, mode, dropbox)
-char * name;
-const mode_t mode;
-const int dropbox;
-{
- int retval;
-#ifdef DROPKLUDGE
- int uid;
-#endif /* DROPKLUDGE */
-
- /* Turn on the sticky bit if this is a drop box, also turn off the setgid bit */
- retval=0;
-#ifdef DROPKLUDGE
- if (dropbox) {
- if (mode & S_IWOTH) {
- if (mode & S_IROTH);
- else { /* if S_IWOTH and not S_IROTH */
- uid=geteuid();
- if ( seteuid(0) < 0) {
- LOG(log_error, logtype_default, "stickydirmode: unable to seteuid root: %s", strerror(errno));
- }
- if ( retval=chmod( name, ( (DIRBITS | mode | S_ISVTX) & ~default_options.umask) ) < 0) {
- LOG(log_error, logtype_default, "stickydirmode: chmod \"%s\": %s", name, strerror(errno) );
- return(AFPERR_ACCESS);
- } else {
-#ifdef DEBUG
- LOG(log_info, logtype_default, "stickydirmode: (debug) chmod \"%s\": %s", name, strerror(retval) );
-#endif /* DEBUG */
- seteuid(uid);
- } /* end getting retval */
- } /* end if not & S_IROTH */
- } else { /* end if S_IWOTH and not S_IROTH */
-#endif /* DROPKLUDGE */
-
- /*
- * Ignore EPERM errors: We may be dealing with a directory that is
- * group writable, in which case chmod will fail.
- */
- if ( (chmod( name, (DIRBITS | mode) & ~default_options.umask ) < 0) && errno != EPERM) {
- LOG(log_error, logtype_default, "stickydirmode: chmod \"%s\": %s",
- name, strerror(errno) );
- retval = -1;
- }
-#ifdef DROPKLUDGE
- } /* end if not mode */
- } /* end checking for "dropbox" */
-#endif /* DROPKLUDGE */
- return retval;
-}