summaryrefslogtreecommitdiffstats
path: root/login-utils/ch-common.c
blob: 34b09f32d30ddfc0e0bedda73cb75143b7829505 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
}