diff options
author | rwatson <rwatson@FreeBSD.org> | 2001-10-25 20:45:47 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2001-10-25 20:45:47 +0000 |
commit | d319d0a53b4227911f8e7c9711955281e80a5281 (patch) | |
tree | a35c0517abf55e70bc28349241a799a766c6de92 /usr.bin | |
parent | 0857f7bbf90575b592c7770dcef6db0c7d9fc87c (diff) | |
download | FreeBSD-src-d319d0a53b4227911f8e7c9711955281e80a5281.zip FreeBSD-src-d319d0a53b4227911f8e7c9711955281e80a5281.tar.gz |
o Modify format of /etc/fbtab to accept glob matching patterns for
target devices, not just individual devices and directories. This
permits activities such as:
ttyv0 0600 /dev/dsp*
Whereas previously that was not supported. This change is
backwards-compatible, except where device names included globbing
characters, which is not the case for any devices listed in MAKEDEV.
Submitted by: Maxime Henrion <mux@qualys.com>
MFC after: 3 weeks
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/login/login_fbtab.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/usr.bin/login/login_fbtab.c b/usr.bin/login/login_fbtab.c index e0b99e3..c3ca5ec 100644 --- a/usr.bin/login/login_fbtab.c +++ b/usr.bin/login/login_fbtab.c @@ -65,7 +65,7 @@ #include <syslog.h> #include <string.h> #include <errno.h> -#include <dirent.h> +#include <glob.h> #include <paths.h> #include <unistd.h> #include "pathnames.h" @@ -121,40 +121,28 @@ gid_t gid; /* login_protect - protect one device entry */ void -login_protect(table, path, mask, uid, gid) -char *table; -char *path; -int mask; -uid_t uid; -gid_t gid; +login_protect(table, pattern, mask, uid, gid) + char *table; + char *pattern; + int mask; + uid_t uid; + gid_t gid; { - char buf[BUFSIZ]; - int pathlen = strlen(path); - struct dirent *ent; - DIR *dir; - - if (strcmp("/*", path + pathlen - 2) != 0) { - /* clear flags of the device */ - if (chflags(path, 0) && errno != ENOENT && errno != EOPNOTSUPP) - syslog(LOG_ERR, "%s: chflags(%s): %m", table, path); - if (chmod(path, mask) && errno != ENOENT) - syslog(LOG_ERR, "%s: chmod(%s): %m", table, path); - if (chown(path, uid, gid) && errno != ENOENT) - syslog(LOG_ERR, "%s: chown(%s): %m", table, path); - } else { - strcpy(buf, path); - buf[pathlen - 1] = 0; - if ((dir = opendir(buf)) == 0) { - syslog(LOG_ERR, "%s: opendir(%s): %m", table, path); - } else { - while ((ent = readdir(dir)) != 0) { - if (strcmp(ent->d_name, ".") != 0 - && strcmp(ent->d_name, "..") != 0) { - strcpy(buf + pathlen - 1, ent->d_name); - login_protect(table, buf, mask, uid, gid); - } - } - closedir(dir); + glob_t gl; + char *path; + int i; + + if (glob(pattern, GLOB_NOSORT, NULL, &gl) != 0) + return; + for (i = 0; i < gl.gl_pathc; i++) { + path = gl.gl_pathv[i]; + /* clear flags of the device */ + if (chflags(path, 0) && errno != ENOENT && errno != EOPNOTSUPP) + syslog(LOG_ERR, "%s: chflags(%s): %m", table, path); + if (chmod(path, mask) && errno != ENOENT) + syslog(LOG_ERR, "%s: chmod(%s): %m", table, path); + if (chown(path, uid, gid) && errno != ENOENT) + syslog(LOG_ERR, "%s: chown(%s): %m", table, path); } - } + globfree(&gl); } |