Add to pwd_mkdb a -q option to silence warnings about large IDs. Add a
suitably ominous warning in the manual page. The diff applied is not the one provided in the attributed PR. PR: 13344 Reviewed by: bde
This commit is contained in:
parent
7cbc47c7bc
commit
18138b08d8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53183
@ -56,6 +56,13 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include "pw_scan.h"
|
#include "pw_scan.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some software assumes that IDs are short. We should emit warnings
|
||||||
|
* for id's which can not be stored in a short, but we are more liberal
|
||||||
|
* by default, warning for IDs greater than USHRT_MAX.
|
||||||
|
*/
|
||||||
|
int pw_big_ids_warning = 1;
|
||||||
|
|
||||||
int
|
int
|
||||||
pw_scan(bp, pw)
|
pw_scan(bp, pw)
|
||||||
char *bp;
|
char *bp;
|
||||||
@ -89,8 +96,8 @@ pw_scan(bp, pw)
|
|||||||
warnx("root uid should be 0");
|
warnx("root uid should be 0");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (id > USHRT_MAX) {
|
if (pw_big_ids_warning && id > USHRT_MAX) {
|
||||||
warnx("%s > max uid value (%d)", p, USHRT_MAX);
|
warnx("%s > max uid value (%u)", p, USHRT_MAX);
|
||||||
/*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
|
/*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
|
||||||
}
|
}
|
||||||
pw->pw_uid = id;
|
pw->pw_uid = id;
|
||||||
@ -99,8 +106,8 @@ pw_scan(bp, pw)
|
|||||||
goto fmt;
|
goto fmt;
|
||||||
if(p[0]) pw->pw_fields |= _PWF_GID;
|
if(p[0]) pw->pw_fields |= _PWF_GID;
|
||||||
id = atol(p);
|
id = atol(p);
|
||||||
if (id > USHRT_MAX) {
|
if (pw_big_ids_warning && id > USHRT_MAX) {
|
||||||
warnx("%s > max gid value (%d)", p, USHRT_MAX);
|
warnx("%s > max gid value (%u)", p, USHRT_MAX);
|
||||||
/* return (0); This should not be fatal! */
|
/* return (0); This should not be fatal! */
|
||||||
}
|
}
|
||||||
pw->pw_gid = id;
|
pw->pw_gid = id;
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
|
* @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
extern int pw_big_ids_warning;
|
||||||
|
|
||||||
extern int pw_scan __P((char *, struct passwd *));
|
extern int pw_scan __P((char *, struct passwd *));
|
||||||
|
@ -56,6 +56,13 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include "pw_scan.h"
|
#include "pw_scan.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some software assumes that IDs are short. We should emit warnings
|
||||||
|
* for id's which can not be stored in a short, but we are more liberal
|
||||||
|
* by default, warning for IDs greater than USHRT_MAX.
|
||||||
|
*/
|
||||||
|
int pw_big_ids_warning = 1;
|
||||||
|
|
||||||
int
|
int
|
||||||
pw_scan(bp, pw)
|
pw_scan(bp, pw)
|
||||||
char *bp;
|
char *bp;
|
||||||
@ -89,8 +96,8 @@ pw_scan(bp, pw)
|
|||||||
warnx("root uid should be 0");
|
warnx("root uid should be 0");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (id > USHRT_MAX) {
|
if (pw_big_ids_warning && id > USHRT_MAX) {
|
||||||
warnx("%s > max uid value (%d)", p, USHRT_MAX);
|
warnx("%s > max uid value (%u)", p, USHRT_MAX);
|
||||||
/*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
|
/*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
|
||||||
}
|
}
|
||||||
pw->pw_uid = id;
|
pw->pw_uid = id;
|
||||||
@ -99,8 +106,8 @@ pw_scan(bp, pw)
|
|||||||
goto fmt;
|
goto fmt;
|
||||||
if(p[0]) pw->pw_fields |= _PWF_GID;
|
if(p[0]) pw->pw_fields |= _PWF_GID;
|
||||||
id = atol(p);
|
id = atol(p);
|
||||||
if (id > USHRT_MAX) {
|
if (pw_big_ids_warning && id > USHRT_MAX) {
|
||||||
warnx("%s > max gid value (%d)", p, USHRT_MAX);
|
warnx("%s > max gid value (%u)", p, USHRT_MAX);
|
||||||
/* return (0); This should not be fatal! */
|
/* return (0); This should not be fatal! */
|
||||||
}
|
}
|
||||||
pw->pw_gid = id;
|
pw->pw_gid = id;
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
|
* @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
extern int pw_big_ids_warning;
|
||||||
|
|
||||||
extern int pw_scan __P((char *, struct passwd *));
|
extern int pw_scan __P((char *, struct passwd *));
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
.Op Fl C
|
.Op Fl C
|
||||||
.Op Fl N
|
.Op Fl N
|
||||||
.Op Fl p
|
.Op Fl p
|
||||||
|
.Op Fl q
|
||||||
.Op Fl d Ar directory
|
.Op Fl d Ar directory
|
||||||
.Op Fl s Ar cachesize
|
.Op Fl s Ar cachesize
|
||||||
.Op Fl u Ar username
|
.Op Fl u Ar username
|
||||||
@ -78,6 +79,12 @@ the rebuilding of the database.
|
|||||||
.It Fl p
|
.It Fl p
|
||||||
Create a Version 7 style password file and install it into
|
Create a Version 7 style password file and install it into
|
||||||
.Pa /etc/passwd .
|
.Pa /etc/passwd .
|
||||||
|
.It Fl q
|
||||||
|
Suppress the warnings that
|
||||||
|
.Nm
|
||||||
|
normally generates for large user and group IDs.
|
||||||
|
Such IDs can cause serious problems with software
|
||||||
|
that makes assumptions about the values of IDs.
|
||||||
.It Fl d Ar directory
|
.It Fl d Ar directory
|
||||||
Store databases into specified destination directory instead of
|
Store databases into specified destination directory instead of
|
||||||
.Pa /etc .
|
.Pa /etc .
|
||||||
|
@ -115,7 +115,7 @@ main(argc, argv)
|
|||||||
strcpy(prefix, _PATH_PWD);
|
strcpy(prefix, _PATH_PWD);
|
||||||
makeold = 0;
|
makeold = 0;
|
||||||
username = NULL;
|
username = NULL;
|
||||||
while ((ch = getopt(argc, argv, "Cd:ps:u:vN")) != -1)
|
while ((ch = getopt(argc, argv, "Cd:pqs:u:vN")) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'C': /* verify only */
|
case 'C': /* verify only */
|
||||||
Cflag = 1;
|
Cflag = 1;
|
||||||
@ -126,6 +126,9 @@ main(argc, argv)
|
|||||||
case 'p': /* create V7 "file.orig" */
|
case 'p': /* create V7 "file.orig" */
|
||||||
makeold = 1;
|
makeold = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
pw_big_ids_warning = 0;
|
||||||
|
break;
|
||||||
case 's': /* change default cachesize */
|
case 's': /* change default cachesize */
|
||||||
openinfo.cachesize = atoi(optarg) * 1024 * 1024;
|
openinfo.cachesize = atoi(optarg) * 1024 * 1024;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user