QNX RTOS 用户登录的密码处理

QNX 用户登录的密码处理文件, passwd.c.

有兴趣的可以参考看看。


/*
 * $QNXLicenseC:
 * Copyright 2007, QNX Software Systems. All Rights Reserved.
 * 
 * You must obtain a written license from and pay applicable license fees to QNX 
 * Software Systems before you may reproduce, modify or distribute this software, 
 * or any work that includes all or part of this software.   Free development 
 * licenses are available for evaluation and non-commercial purposes.  For more 
 * information visit http://licensing.qnx.com or email licensing@qnx.com.
 *  
 * This file may contain contributions from others.  Please review this entire 
 * file for other proprietary rights or license notices, as well as the QNX 
 * Development Suite License Guide at http://licensing.qnx.com/license-guide/ 
 * for other information.
 * $
 */










/*-


passwd: change passwd or create initial passwd entry.

24,july,91: steve
- don't make invalid uid/gid root
- more careful in creating home directory




$Log$
Revision 1.10  2006/05/29 16:11:43  rmansfield
PR: 38017
CI: kewarken


Fixed off-by-one error.


Revision 1.9  2006/05/04 18:52:35  rmansfield
PR: 23548
CI: kewarken


Last change reverted warnings cleanup of PR23548.


Revision 1.8  2006/05/04 18:20:26  rmansfield
PR: 38017
CI: kewarken


Use strncpy instead of strcpy.


Revision 1.7  2006/04/11 16:16:03  rmansfield


PR: 23548
CI: kewarken


Stage 1 of the warnings/errors cleanup.


Revision 1.6  2005/06/03 01:37:53  adanko


Replace existing QNX copyright licence headers with macros as specified by
the QNX Coding Standard. This is a change to source files in the head branch
only.


Note: only comments were changed.


PR25328


Revision 1.5  2004/05/17 16:26:41  rcraig
PR 20236: Login and su have inconsistent user name length checking and passwd has none at all (but doesn't work when the user name exceeds 995 characters).  "chklogin.c" in lib/login/c also uses L_cuserid to check for the username length.  In order to provide consistency, the macro LOGIN_NAME_MAX in limits.h has been defined and set to 256 initially.


For building, make sure that libc has been installed with the most up todate version since the old limits.h file won't have the macro defined.


Revision 1.4  2003/08/27 18:04:34  martin
Add QSSL Copyright.


Revision 1.3  1999/12/09 18:43:15  thomasf
Added the ability to use the /etc/default/passwd file
to specify either QNX4 type crypt of UNIX type crypt
rather than prompt the user.  By default it uses
the UNIX crypt (Neutrino only) if the QNXCRYPT specifier
is not set in the file.


Revision 1.2  1999/08/03 18:02:23  thomasf
Fixed the local declaration of qnx_crypt to be const char *


Revision 1.1.1.1  1999/07/14 14:47:34  thomasf
passwd migrated from QNX4


Revision 1.6  1997/03/07 20:11:16  eric
lock_passwd in login lib changed to return appropriate errno
instead of timing out when an error other than EEXIST is returned
when trying to open() the password lock file (/etc/.passwd).
When unable to lock password file, passwd now will print
the reason why (normally EBUSY, but could be something else).


Revision 1.5  1997/03/07 16:06:43  steve
*** empty log message ***


 * Revision 1.4  1993/11/30  21:34:55  steve
 * Changed error message for too simple of a password to match reality.
 *
 * Revision 1.3  1993/11/30  21:30:29  steve
 * *** empty log message ***
 *
*/


#include <libc.h>
#include <pwd.h>
#include <grp.h>
#include <shadow.h>
#include <limits.h>
#include <unistd.h>
#include <libgen.h>
#include <sys/timeb.h>
#include <sys/stat.h>
#include <util/stdutil.h>


#include "login.h"


//extern char *crypt(char *key, char *salt);
//extern char *getpass(char *prompt);
//extern int new_salt(char *salt);
#if defined(__QNXNTO__)
extern int new_salt(char *salt);
#define USE_QNX_CRYPT 0x1
#define USE_UNIX_CRYPT 0x2


#else
#include <crypt.h>
#include <login.h>
#endif


#define NORMAL_PASSWD "x"
#define CHROOTED_PASSWD "*"


char     *passwd_stub = NORMAL_PASSWD;
char     *nil_passwd = "";




#define PWLEN 32


int enter_uid() {
long            uid;
long            low, hi;
struct passwd  *pw;


if (getdef_range("UIDRANGE", &low, &hi) < 2) {
low = 0;
hi = UINT_MAX;
}


while (1) {
uid = guess_uid();
if (inputval_range("User id #", low, hi, uid, &uid) == -1)
return -1;
if ((pw = getpwuid(uid)) != NULL) {
if (getdef_bool("DUPUIDOK")) {
fprintf(stderr, "warning, userid %ld is already in use\n", uid);
} else {
fprintf(stderr, "error, userid %ld is already in use\n", uid);
fprintf(stderr, "you are not permitted to share userids\n");
}
continue;
}
return uid;
}
}




int enter_gid() {
long            gid;
long low, hi;
struct group   *gr;


if (getdef_range("GIDRANGE", &low, &hi) < 2) {
low = 0;
hi = UINT_MAX;
}
while (1) {
gid = guess_

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值