+2001-10-23 jeff b <jeff@univrel.pr.uconn.edu>
+
+ * etc/afpd/{{afpd_options,filedir,main,unix}.c,
+ {filedir,globals,unix}.h}: patch from Edmund Lam to allow
+ perms masks
+
2001-10-21 joe c <marcus@marcuscom.com>
* libatalk/cnid*.c: Big patch to improve transaction throughput
/*
- * $Id: afp_options.c,v 1.12 2001-09-19 03:08:40 jmarcus Exp $
+ * $Id: afp_options.c,v 1.13 2001-10-23 13:44:37 rufustfirefly Exp $
*
* Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
* Copyright (c) 1990,1993 Regents of The University of Michigan.
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif /* MIN */
-#define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:Iv"
+#define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:Ivm:"
#define LENGTH 512
/* return an option. this uses an internal array, so it's necessary
options->passwdfile = _PATH_AFPDPWFILE;
options->tickleval = 30;
options->authprintdir = NULL;
+ options->umask = 0;
#ifdef ADMIN_GRP
options->admingid = 0;
#endif /* ADMIN_GRP */
extern int optind;
char *p;
+ char *tmp; /* Used for error checking the result of strtol */
int c, err = 0;
if (gethostname(options->hostname, sizeof(options->hostname )) < 0 ) {
case 'I':
options->flags |= OPTION_CUSTOMICON;
break;
+ case 'm':
+ options->umask = strtol(optarg, &tmp, 8);
+ if ((options->umask < 0) || (options->umask > 0777)) {
+ fprintf(stderr, "%s: out of range umask setting provided\n", p);
+ err++;
+ }
+ if (tmp[0] != '\0') {
+ fprintf(stderr, "%s: invalid characters in umask setting provided\n", p);
+ err++;
+ }
+ break;
default :
err++;
}
/*
- * $Id: filedir.c,v 1.14 2001-09-06 20:00:59 rufustfirefly Exp $
+ * $Id: filedir.c,v 1.15 2001-10-23 13:44:37 rufustfirefly Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
upath, strerror(errno));
return (AFPERR_ACCESS);
}
- if (chmod(upath,(st.st_mode&0x0FFFF)| S_IRGRP| S_IROTH) < 0)
+ if (chmod(upath,(st.st_mode&0777&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
{
syslog (LOG_ERR,
"matchfile2dirperms: Error adding file read permissions: %s",
adpath, strerror(errno));
return (AFPERR_ACCESS);
}
- if (chmod(adpath, (st.st_mode&0x0FFFF)| S_IRGRP| S_IROTH) < 0)
+ if (chmod(adpath, (st.st_mode&0777&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
{
syslog (LOG_ERR,
"matchfile2dirperms: Error adding AD file read permissions: %s",
/*
- * $Id: filedir.h,v 1.4 2001-09-05 13:30:16 rufustfirefly Exp $
+ * $Id: filedir.h,v 1.5 2001-10-23 13:44:37 rufustfirefly Exp $
*/
#ifndef AFPD_FILEDIR_H
#include "globals.h"
#include "volume.h"
+extern struct afp_options default_options;
+
extern char *ctoupath __P((const struct vol *, struct dir *,
char *));
extern int veto_file __P((const char *veto_str, const char *path));
/*
- * $Id: globals.h,v 1.5 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: globals.h,v 1.6 2001-10-23 13:44:37 rufustfirefly Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
char *guest, *loginmesg, *keyfile, *passwdfile;
char *uamlist;
char *authprintdir;
+ mode_t umask;
#ifdef ADMIN_GRP
gid_t admingid;
#endif /* ADMIN_GRP */
/*
- * $Id: main.c,v 1.11 2001-08-15 01:37:34 srittau Exp $
+ * $Id: main.c,v 1.12 2001-10-23 13:44:37 rufustfirefly Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
set_auth_parameters( ac, av );
#endif /* TRU64 */
- umask( 0 ); /* so inherited file permissions work right */
+ umask( 022 ); /* so inherited file permissions work right */
afp_options_init(&default_options);
if (!afp_options_parse(ac, av, &default_options))
exit(1);
+
+ umask( default_options.umask );
switch(server_lock("afpd", default_options.pidfile,
default_options.flags & OPTION_DEBUG)) {
/*
- * $Id: unix.c,v 1.23 2001-10-10 16:05:37 srittau Exp $
+ * $Id: unix.c,v 1.24 2001-10-23 13:44:37 rufustfirefly Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
if ( seteuid(0) < 0) {
syslog( LOG_ERR, "stickydirmode: unable to seteuid root: %m");
}
- if ( retval=chmod( name, ( DIRBITS | mode | S_ISVTX) ) < 0) {
+ if ( retval=chmod( name, ( (DIRBITS | mode | S_ISVTX) & 0777 & ~default_options.umask) ) < 0) {
syslog( LOG_ERR, "stickydirmode: chmod \"%s\": %m", name );
return(AFPERR_ACCESS);
} else {
* 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 ) < 0 && errno != EPERM) {
+ if ( (chmod( name, (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0) && errno != EPERM) {
syslog( LOG_ERR, "stickydirmode: chmod \"%s\": %s",
name, strerror(errno) );
retval = -1;
}
if (S_ISDIR(st.st_mode)) {
- if ( chmod( modbuf, DIRBITS | mode ) < 0 && errno != EPERM ) {
+ if ( chmod( modbuf, (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
syslog( LOG_ERR, "setdeskmode: chmod %s: %s",
modbuf, strerror(errno) );
}
- } else if ( chmod( modbuf, mode ) < 0 && errno != EPERM ) {
+ } else if ( chmod( modbuf, mode & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
syslog( LOG_ERR, "setdeskmode: chmod %s: %s",
modbuf, strerror(errno) );
}
}
closedir( sub );
/* XXX: need to preserve special modes */
- if ( chmod( deskp->d_name, DIRBITS | mode ) < 0 && errno != EPERM ) {
+ if ( chmod( deskp->d_name, (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
syslog( LOG_ERR, "setdeskmode: chmod %s: %s",
deskp->d_name, strerror(errno) );
}
return -1;
}
/* XXX: need to preserve special modes */
- if ( chmod( ".AppleDesktop", DIRBITS | mode ) < 0 && errno != EPERM ) {
+ if ( chmod( ".AppleDesktop", (DIRBITS | mode) & 0777 & ~default_options.umask ) < 0 && errno != EPERM ) {
syslog( LOG_ERR, "setdeskmode: chmod .AppleDesktop: %s", strerror(errno) );
}
return( 0 );
/*
- * $Id: unix.h,v 1.7 2001-06-20 18:33:04 rufustfirefly Exp $
+ * $Id: unix.h,v 1.8 2001-10-23 13:44:37 rufustfirefly Exp $
*/
#ifndef AFPD_UNIX_H
const u_int32_t));
#endif /* NO_QUOTA_SUPPORT */
+extern struct afp_options default_options;
+
extern int gmem __P((const gid_t));
extern int setdeskmode __P((const mode_t));
extern int setdirmode __P((const mode_t, const int, const int));