[Libsysio-commit] HEAD: libsysio/drivers/incore fs_incore.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-03-09 19:35:31
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv32320/drivers/incore Modified Files: fs_incore.c Log Message: Various permission checks are implemented in the library now. When run as a normal user (almost always the case) we now need a way to create incore file systems with owner and group set to that of the creator instead of some hard value from an init string. This change: 1) Makes the user and group modifiers to the type argument optional. 2) Changes the syntax of that modifier -- BEWARE! It is now [+<uid>][-<gid>]. Existing init strings will definately break with this change. I hate saying it but it will be because "it's not a bug, it's a feature." Ugh. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- fs_incore.c 4 Aug 2005 20:17:09 -0000 1.24 +++ fs_incore.c 9 Mar 2007 19:35:27 -0000 1.25 @@ -546,29 +546,40 @@ _sysio_incore_fsswop_mount(const char *s * Source is a specification for the root attributes of this * new file system in the format: * - * <permissions>+<owner>+<group> + * <permissions>[+<owner>][-<group>] */ ul = strtoul(source, &cp, 0); mode = (mode_t )ul & 07777; - if (*cp != '+' || - (ul == ULONG_MAX && errno == ERANGE) || + uid = getuid(); /* default */ + gid = getgid(); /* default */ + while (*cp != '\0') { + /* + * Get user and/or group. + */ + if (*cp == '+') { + if ((ul == ULONG_MAX && errno == ERANGE) || (unsigned long)mode != ul || mode > 07777) return -EINVAL; source = cp; l = strtol(source, &cp, 0); uid = (uid_t )l; - if (*cp != '+' || - ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || + if (((l == LONG_MIN || l == LONG_MAX) && + errno == ERANGE) || (long )uid != l) return -EINVAL; + } + if (*cp == '-') { source = cp; l = strtol(source, &cp, 0); gid = (gid_t )l; - if (*cp || - ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) || + if (((l == LONG_MIN || l == LONG_MAX) && + errno == ERANGE) || (long )gid != l) return -EINVAL; + } + return -EINVAL; + } err = 0; |