Date: Sat, 23 Mar 2002 00:56:31 +0000 From: markm@freebsd.org To: audit@freebsd.org Subject: chpass WARNS/lint fixes Message-ID: <200203230056.g2N0uV1D047229@grimreaper.grondar.org>
next in thread | raw e-mail | index | archive | help
Index: Makefile
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/Makefile,v
retrieving revision 1.24
diff -u -d -r1.24 Makefile
--- Makefile 13 Sep 2001 06:48:16 -0000 1.24
+++ Makefile 23 Mar 2002 00:51:47 -0000
@@ -2,7 +2,6 @@
# $FreeBSD: src/usr.bin/chpass/Makefile,v 1.24 2001/09/13 06:48:16 ru Exp $
PROG= chpass
-CFLAGS+=-Wall
SRCS= chpass.c edit.c field.c pw_copy.c pw_scan.c pw_util.c pw_yp.c \
table.c util.c ypxfr_misc.c ${GENSRCS}
GENSRCS=yp.h yp_clnt.c yppasswd.h yppasswd_clnt.c yppasswd_private.h \
Index: chpass.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/chpass.c,v
retrieving revision 1.20
diff -u -d -r1.20 chpass.c
--- chpass.c 22 Mar 2002 01:19:26 -0000 1.20
+++ chpass.c 23 Mar 2002 00:45:13 -0000
@@ -39,10 +39,11 @@
#ifndef lint
static const char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94";
-static const char rcsid[] =
- "$FreeBSD: src/usr.bin/chpass/chpass.c,v 1.20 2002/03/22 01:19:26 imp Exp $";
#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/signal.h>
@@ -77,6 +78,8 @@
void baduser(void);
void usage(void);
+char localhost[] = "localhost";
+
int
main(argc, argv)
int argc;
@@ -135,7 +138,7 @@
#endif
yp_domain = optarg;
if (yp_server == NULL)
- yp_server = "localhost";
+ yp_server = localhost;
#ifdef PARANOID
}
#endif
Index: chpass.h
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/chpass.h,v
retrieving revision 1.4
diff -u -d -r1.4 chpass.h
--- chpass.h 22 Mar 2002 01:19:26 -0000 1.4
+++ chpass.h 23 Mar 2002 00:49:56 -0000
@@ -37,8 +37,9 @@
struct passwd;
typedef struct _entry {
- char *prompt;
- int (*func)(), restricted, len;
+ const char *prompt;
+ int (*func)(char *, struct passwd *, struct _entry *);
+ int restricted, len;
char *except, *save;
} ENTRY;
Index: edit.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/edit.c,v
retrieving revision 1.19
diff -u -d -r1.19 edit.c
--- edit.c 26 Jul 2001 23:27:10 -0000 1.19
+++ edit.c 23 Mar 2002 00:45:42 -0000
@@ -29,14 +29,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD: src/usr.bin/chpass/edit.c,v 1.19 2001/07/26 23:27:10 mike Exp $
*/
#ifndef lint
static const char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/stat.h>
@@ -100,7 +101,7 @@
struct passwd *pw;
{
FILE *fp;
- char *bp, *p, *ttoa();
+ char *bp, *p;
if (!(fp = fdopen(fd, "w")))
pw_error(tempname, 1, 1);
@@ -260,7 +261,7 @@
pw->pw_name, pw->pw_passwd, (unsigned long)pw->pw_uid,
(unsigned long)pw->pw_gid, pw->pw_class, (long)pw->pw_change,
(long)pw->pw_expire, pw->pw_gecos, pw->pw_dir,
- pw->pw_shell) >= sizeof(buf)) {
+ pw->pw_shell) >= (int)sizeof(buf)) {
warnx("entries too long");
free(p);
return (0);
Index: field.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/field.c,v
retrieving revision 1.4
diff -u -d -r1.4 field.c
--- field.c 6 Dec 1998 22:58:14 -0000 1.4
+++ field.c 23 Mar 2002 00:45:59 -0000
@@ -35,6 +35,9 @@
static const char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94";
#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/param.h>
#include <sys/stat.h>
@@ -56,7 +59,7 @@
p_login(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
if (!*p) {
warnx("empty login field");
@@ -85,10 +88,10 @@
p_passwd(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
if (!*p)
- pw->pw_passwd = ""; /* "NOLOGIN"; */
+ pw->pw_passwd = strdup(""); /* "NOLOGIN"; */
else if (!(pw->pw_passwd = strdup(p))) {
warnx("can't save password entry");
return (1);
@@ -102,7 +105,7 @@
p_uid(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
uid_t id;
char *np;
@@ -130,7 +133,7 @@
p_gid(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
struct group *gr;
gid_t id;
@@ -163,10 +166,10 @@
p_class(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
if (!*p)
- pw->pw_class = "";
+ pw->pw_class = strdup("");
else if (!(pw->pw_class = strdup(p))) {
warnx("can't save entry");
return (1);
@@ -180,7 +183,7 @@
p_change(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
if (!atot(p, &pw->pw_change))
return (0);
@@ -193,7 +196,7 @@
p_expire(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
if (!atot(p, &pw->pw_expire))
return (0);
@@ -205,11 +208,11 @@
int
p_gecos(p, pw, ep)
char *p;
- struct passwd *pw;
+ struct passwd *pw __unused;
ENTRY *ep;
{
if (!*p)
- ep->save = "";
+ ep->save = strdup("");
else if (!(ep->save = strdup(p))) {
warnx("can't save entry");
return (1);
@@ -222,7 +225,7 @@
p_hdir(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
if (!*p) {
warnx("empty home directory field");
@@ -240,13 +243,13 @@
p_shell(p, pw, ep)
char *p;
struct passwd *pw;
- ENTRY *ep;
+ ENTRY *ep __unused;
{
- char *t, *ok_shell();
+ char *t;
struct stat sbuf;
if (!*p) {
- pw->pw_shell = _PATH_BSHELL;
+ pw->pw_shell = strdup(_PATH_BSHELL);
return (0);
}
/* only admin can change from or to "restricted" shells */
Index: pw_copy.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/pw_copy.c,v
retrieving revision 1.11
diff -u -d -r1.11 pw_copy.c
--- pw_copy.c 18 Mar 2002 02:22:53 -0000 1.11
+++ pw_copy.c 23 Mar 2002 00:46:11 -0000
@@ -37,6 +37,9 @@
static const char sccsid[] = "@(#)pw_copy.c 8.4 (Berkeley) 4/2/94";
#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
/*
* This module is used to copy the master password file, replacing a single
* record, by chpass(1) and passwd(1).
Index: pw_yp.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/pw_yp.c,v
retrieving revision 1.19
diff -u -d -r1.19 pw_yp.c
--- pw_yp.c 6 Feb 2002 15:26:04 -0000 1.19
+++ pw_yp.c 23 Mar 2002 00:46:33 -0000
@@ -34,35 +34,37 @@
* Written by Bill Paul <wpaul@ctr.columbia.edu>
* Center for Telecommunications Research
* Columbia University, New York City
- *
- * $FreeBSD: src/usr.bin/chpass/pw_yp.c,v 1.19 2002/02/06 15:26:04 des Exp $
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#ifdef YP
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <netdb.h>
-#include <time.h>
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/stat.h>
-#include <pwd.h>
-#include <errno.h>
-#include <err.h>
-#include <unistd.h>
-#include <db.h>
-#include <fcntl.h>
-#include <utmp.h>
-#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/param.h>
-#include <limits.h>
+#include <sys/types.h>
#include <rpc/rpc.h>
#include <rpcsvc/yp.h>
-struct dom_binding {};
#include <rpcsvc/ypclnt.h>
#include <rpcsvc/yppasswd.h>
+#include <db.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <netdb.h>
#include <pw_util.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <utmp.h>
+
+struct dom_binding {};
+
#include "pw_yp.h"
#include "ypxfr_extern.h"
#include "yppasswd_private.h"
Index: table.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/table.c,v
retrieving revision 1.7
diff -u -d -r1.7 table.c
--- table.c 23 Feb 1999 02:41:26 -0000 1.7
+++ table.c 23 Mar 2002 00:46:44 -0000
@@ -35,6 +35,9 @@
static const char sccsid[] = "@(#)table.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/types.h>
#include <stddef.h>
#include "chpass.h"
@@ -43,23 +46,23 @@
char e2[] = ":,";
ENTRY list[] = {
- { "login", p_login, 1, 5, e1, },
- { "password", p_passwd, 1, 8, e1, },
- { "uid", p_uid, 1, 3, e1, },
- { "gid", p_gid, 1, 3, e1, },
- { "class", p_class, 1, 5, e1, },
- { "change", p_change, 1, 6, NULL, },
- { "expire", p_expire, 1, 6, NULL, },
+ { "login", p_login, 1, 5, e1, NULL },
+ { "password", p_passwd, 1, 8, e1, NULL },
+ { "uid", p_uid, 1, 3, e1, NULL },
+ { "gid", p_gid, 1, 3, e1, NULL },
+ { "class", p_class, 1, 5, e1, NULL },
+ { "change", p_change, 1, 6, NULL, NULL },
+ { "expire", p_expire, 1, 6, NULL, NULL },
#ifdef RESTRICT_FULLNAME_CHANGE /* do not allow fullname changes */
- { "full name", p_gecos, 1, 9, e2, },
+ { "full name", p_gecos, 1, 9, e2, NULL },
#else
- { "full name", p_gecos, 0, 9, e2, },
+ { "full name", p_gecos, 0, 9, e2, NULL },
#endif
- { "office phone", p_gecos, 0, 12, e2, },
- { "home phone", p_gecos, 0, 10, e2, },
- { "office location", p_gecos, 0, 15, e2, },
- { "other information", p_gecos, 0, 11, e1, },
- { "home directory", p_hdir, 1, 14, e1, },
- { "shell", p_shell, 0, 5, e1, },
- { NULL, 0, },
+ { "office phone", p_gecos, 0, 12, e2, NULL },
+ { "home phone", p_gecos, 0, 10, e2, NULL },
+ { "office location", p_gecos, 0, 15, e2, NULL },
+ { "other information", p_gecos, 0, 11, e1, NULL },
+ { "home directory", p_hdir, 1, 14, e1, NULL },
+ { "shell", p_shell, 0, 5, e1, NULL },
+ { NULL, NULL, 0, 0, NULL, NULL },
};
Index: util.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/util.c,v
retrieving revision 1.9
diff -u -d -r1.9 util.c
--- util.c 18 Mar 2002 09:49:18 -0000 1.9
+++ util.c 23 Mar 2002 00:46:57 -0000
@@ -32,13 +32,12 @@
*/
#ifndef lint
-#if 0
-static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD: src/usr.bin/chpass/util.c,v 1.9 2002/03/18 09:49:18 cjc Exp $";
+static const char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
#include <sys/types.h>
#include <ctype.h>
@@ -52,7 +51,7 @@
#include "chpass.h"
#include "pathnames.h"
-static char *months[] =
+static const char *months[] =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December", NULL };
@@ -80,7 +79,8 @@
time_t *store;
{
static struct tm *lt;
- char *t, **mp;
+ char *t;
+ const char **mp;
time_t tval;
int day, month, year;
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203230056.g2N0uV1D047229>
