This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
基本的 gnu/linux 用户名是一个 32 个字符的字符串 (
useradd(8)
)。这是 BSD 4.3 标准的旧格式。passwd(5)
添加了一些额外的限制,例如,不要使用大写字母,不要使用点,不要以破折号结尾,不得包含冒号。为了安全起见,请遵循 C 标识符的相同规则:
这就是问题的一半。现代 GNU/Linux 发行版使用 PAM 进行用户身份验证。有了它,您可以选择任何您想要的规则以及任何数据源。
由于您正在编写程序,因此最好定义自己的格式,然后使用
pam_ldap
、pam_mysql
等来访问它。A basic gnu/linux username is a 32 character string (
useradd(8)
). This is a legacy format from the BSD 4.3 standard.passwd(5)
adds some additional restrictions like, do not use capital letters, do not use dots, do not end it in dash, it must not include colons.To be on the safe side of things, follow the same rules of a C identifier:
That's half the problem. Modern GNU/Linux distributions use PAM for user authentication. With it you can choose any rule you want and also any data source.
Since you are writing a program it's better to define your own format, and then use something like
pam_ldap
,pam_mysql
, etc. to access it.