summaryrefslogtreecommitdiffstats
path: root/login-utils/ch-common.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:14:44 +0000
commit30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch)
tree9b788335f92174baf7ee18f03ca8330b8c19ce2b /login-utils/ch-common.c
parentInitial commit. (diff)
downloadutil-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.tar.xz
util-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.zip
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'login-utils/ch-common.c')
-rw-r--r--login-utils/ch-common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/login-utils/ch-common.c b/login-utils/ch-common.c
new file mode 100644
index 0000000..34b09f3
--- /dev/null
+++ b/login-utils/ch-common.c
@@ -0,0 +1,34 @@
+/*
+ * chfn and chsh shared functions
+ *
+ * this program is free software. you can redistribute it and
+ * modify it under the terms of the gnu general public license.
+ * there is no warranty.
+ */
+
+#include <ctype.h>
+#include <string.h>
+
+#include "c.h"
+#include "nls.h"
+
+#include "ch-common.h"
+
+/*
+ * illegal_passwd_chars () -
+ * check whether a string contains illegal characters
+ */
+int illegal_passwd_chars(const char *str)
+{
+ const char illegal[] = ",:=\"\n";
+ const size_t len = strlen(str);
+ size_t i;
+
+ if (strpbrk(str, illegal))
+ return 1;
+ for (i = 0; i < len; i++) {
+ if (iscntrl(str[i]))
+ return 1;
+ }
+ return 0;
+}