diff --git a/libselinux/ChangeLog b/libselinux/ChangeLog index 984d86a71..bf7a213af 100644 --- a/libselinux/ChangeLog +++ b/libselinux/ChangeLog @@ -1,3 +1,7 @@ +1.27.10 2005-10-17 + * Changed getseuserbyname to ignore empty lines and to handle + no matching entry in the same manner as no seusers file. + 1.27.9 2005-10-13 * Changed selinux_mkload_policy to try downgrading the latest policy version available to the kernel-supported version. diff --git a/libselinux/VERSION b/libselinux/VERSION index 2151d61da..3fdfffce3 100644 --- a/libselinux/VERSION +++ b/libselinux/VERSION @@ -1 +1 @@ -1.27.9 +1.27.10 diff --git a/libselinux/src/seusers.c b/libselinux/src/seusers.c index 2b6c42dd7..926b14967 100644 --- a/libselinux/src/seusers.c +++ b/libselinux/src/seusers.c @@ -26,9 +26,9 @@ static int process_seusers(const char *buffer, start = newbuf; while (isspace(*start)) start++; - if (*start == '#') { + if (*start == '#' || *start == 0) { free(newbuf); - return -1; /* Comment, skip over */ + return -1; /* Comment or empty line, skip over */ } end = strchr(start, ':'); if (!end) @@ -98,16 +98,8 @@ int getseuserbyname(const char *name, char **r_seuser, char **r_level) { char *defaultlevel=NULL; cfg = fopen(selinux_usersconf_path(), "r"); - if (!cfg) { - if (require_seusers) - return -1; - /* Fall back to the Linux username and no level. */ - *r_seuser = strdup(name); - if (!(*r_seuser)) - return -1; - *r_level = NULL; - return 0; - } + if (!cfg) + goto nomatch; while (getline(&buffer, &size, cfg) > 0) { ++lineno; @@ -138,6 +130,7 @@ int getseuserbyname(const char *name, char **r_seuser, char **r_level) { if (buffer) free(buffer); fclose(cfg); + if (seuser) { free(username); free(defaultseuser); @@ -152,6 +145,15 @@ int getseuserbyname(const char *name, char **r_seuser, char **r_level) { *r_level = defaultlevel; return 0; } - - return -1; + +nomatch: + if (require_seusers) + return -1; + + /* Fall back to the Linux username and no level. */ + *r_seuser = strdup(name); + if (!(*r_seuser)) + return -1; + *r_level = NULL; + return 0; }