chiark / gitweb /
sysusers: allow the shell to be specified
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Jan 2018 13:28:10 +0000 (14:28 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:58:48 +0000 (07:58 +0200)
This is necessary for some system users where the "login shell" is
set to a specific binary.

src/basic/user-util.c
src/basic/user-util.h

index ecb1e5fc8dec898a5b4b24c6b3ee94fa0ff20678..defc30ba9baf0fe1e5257fd205695fec18046982 100644 (file)
@@ -653,6 +653,8 @@ bool valid_gecos(const char *d) {
 }
 
 bool valid_home(const char *p) {
+        /* Note that this function is also called by valid_shell(), any
+         * changes must account for that. */
 
         if (isempty(p))
                 return false;
index 6b2f1af52349cb7645b7be3e24fd80c2a93192c2..2bd1ee9a76ed0ad7a9fb81a95dea9fefced5d844 100644 (file)
@@ -108,6 +108,15 @@ bool valid_user_group_name_or_id(const char *u);
 bool valid_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);
+}
+
 int maybe_setgroups(size_t size, const gid_t *list);
 
 bool synthesize_nobody(void);