user-util: tighten shell validation a tiny bit
This commit is contained in:
@@ -884,6 +884,17 @@ bool valid_home(const char *p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool valid_shell(const char *p) {
|
||||
/* We have the same requirements, so just piggy-back on the home check.
|
||||
*
|
||||
* Let's ignore /etc/shells because this is only applicable to real and not system users. It is also
|
||||
* incompatible with the idea of empty /etc/. */
|
||||
if (!valid_home(p))
|
||||
return false;
|
||||
|
||||
return !endswith(p, "/"); /* one additional restriction: shells may not be dirs */
|
||||
}
|
||||
|
||||
int maybe_setgroups(size_t size, const gid_t *list) {
|
||||
int r;
|
||||
|
||||
|
||||
@@ -108,15 +108,7 @@ bool valid_user_group_name(const char *u, ValidUserFlags flags);
|
||||
bool valid_gecos(const char *d);
|
||||
char* mangle_gecos(const char *d);
|
||||
bool valid_home(const char *p);
|
||||
|
||||
static inline bool valid_shell(const char *p) {
|
||||
/* We have the same requirements, so just piggy-back on the home check.
|
||||
*
|
||||
* Let's ignore /etc/shells because this is only applicable to real and
|
||||
* not system users. It is also incompatible with the idea of empty /etc.
|
||||
*/
|
||||
return valid_home(p);
|
||||
}
|
||||
bool valid_shell(const char *p);
|
||||
|
||||
int maybe_setgroups(size_t size, const gid_t *list);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user