summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/Config.in12
-rw-r--r--loginutils/addgroup.c3
-rw-r--r--loginutils/adduser.c1
3 files changed, 16 insertions, 0 deletions
diff --git a/loginutils/Config.in b/loginutils/Config.in
index 81d05ef..c57d997 100644
--- a/loginutils/Config.in
+++ b/loginutils/Config.in
@@ -82,6 +82,18 @@ config FEATURE_DEL_USER_FROM_GROUP
If called with two non-option arguments, deluser
or delgroup will remove an user from a specified group.
+config FEATURE_CHECK_NAMES
+ bool "Enable sanity check on user/group names in adduser and addgroup"
+ default n
+ depends on ADDUSER || ADDGROUP
+ help
+ Enable sanity check on user and group names in adduser and addgroup.
+ To avoid problems, the user or group name should consist only of
+ letters, digits, underscores, periods, at signs and dashes,
+ and not start with a dash (as defined by IEEE Std 1003.1-2001).
+ For compatibility with Samba machine accounts "$" is also supported
+ at the end of the user or group name.
+
config ADDUSER
bool "adduser"
default n
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index b25f817..367c6b9 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -173,8 +173,11 @@ int addgroup_main(int argc ATTRIBUTE_UNUSED, char **argv)
#endif
} else
#endif /* ENABLE_FEATURE_ADDUSER_TO_GROUP */
+ {
+ die_if_bad_username(argv[0]);
new_group(argv[0], gid);
+ }
/* Reached only on success */
return EXIT_SUCCESS;
}
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index d409eab..cd68015 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -111,6 +111,7 @@ int adduser_main(int argc ATTRIBUTE_UNUSED, char **argv)
/* fill in the passwd struct */
pw.pw_name = argv[0];
+ die_if_bad_username(pw.pw_name);
if (!pw.pw_dir) {
/* create string for $HOME if not specified already */
pw.pw_dir = xasprintf("/home/%s", argv[0]);