-# $OpenBSD: Makefile,v 1.11 2016/03/30 06:38:46 jmc Exp $
+# $OpenBSD: Makefile,v 1.12 2018/09/16 02:38:57 millert Exp $
PROG= mail
SRCS= version.c aux.c cmd1.c cmd2.c cmd3.c cmdtab.c collect.c \
- edit.c fio.c getname.c head.c v7.local.c lex.c list.c main.c names.c \
+ edit.c fio.c head.c v7.local.c lex.c list.c main.c names.c \
popen.c quit.c send.c strings.c temp.c tty.c vars.c
SFILES= mail.help mail.tildehelp
EFILES= mail.rc
-/* $OpenBSD: aux.c,v 1.29 2015/10/16 17:56:07 mmcc Exp $ */
+/* $OpenBSD: aux.c,v 1.30 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
* Return a pointer to a dynamic copy of the argument.
*/
char *
-savestr(char *str)
+savestr(const char *str)
{
char *new;
int size = strlen(str) + 1;
-/* $OpenBSD: extern.h,v 1.28 2015/01/20 16:59:07 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.29 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: extern.h,v 1.7 1997/07/09 05:22:00 mikel Exp $ */
/*-
* SUCH DAMAGE.
*
* @(#)extern.h 8.2 (Berkeley) 4/20/95
- * $OpenBSD: extern.h,v 1.28 2015/01/20 16:59:07 millert Exp $
+ * $OpenBSD: extern.h,v 1.29 2018/09/16 02:38:57 millert Exp $
*/
struct name;
struct name *cat(struct name *, struct name *);
-struct name *delname(struct name *, char *);
+struct name *delname(struct name *, const char *);
struct name *elide(struct name *);
struct name *extract(char *, int);
struct grouphead;
char *detract(struct name *, int);
char *expand(char *);
char *getdeadletter(void);
-char *getname(uid_t);
struct message;
char *hfield(char *, struct message *);
FILE *infix(struct header *, FILE *);
char *reedit(char *);
FILE *run_editor(FILE *, off_t, int, int);
char *salloc(int);
-char *savestr(char *);
+char *savestr(const char *);
FILE *setinput(struct message *);
char *skin(char *);
char *skip_comment(char *);
char *snarf(char *, int *);
-char *username(void);
+const char
+ *username(void);
char *value(char *);
char *vcopy(char *);
char *yankword(char *, char *);
int file(void *);
struct grouphead *
findgroup(char *);
-void findmail(char *, char *, int);
+void findmail(const char *, char *, int);
void fioint(int);
int first(int, int);
void fixhead(struct header *, struct name *);
int gethfromtty(struct header *, int);
int getmsglist(char *, int *, int);
int getrawlist(char *, char **, int);
-uid_t getuserid(char *);
int grabh(struct header *, int);
int group(void *);
int hash(char *);
+++ /dev/null
-/* $OpenBSD: getname.c,v 1.8 2009/10/27 23:59:40 deraadt Exp $ */
-/* $NetBSD: getname.c,v 1.4 1996/06/08 19:48:23 christos Exp $ */
-
-/*
- * Copyright (c) 1980, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * 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.
- */
-
-#include "rcv.h"
-#include <pwd.h>
-#include "extern.h"
-
-/* Getname / getuserid for those with hashed passwd data base. */
-
-/*
- * Search the passwd file for a uid. Return name on success, NULL on failure
- */
-char *
-getname(uid_t uid)
-{
- struct passwd *pw;
-
- if ((pw = getpwuid(uid)) == NULL)
- return(NULL);
- return(pw->pw_name);
-}
-
-/*
- * Convert the passed name to a user id and return it. Return -1
- * on error.
- */
-uid_t
-getuserid(char *name)
-{
- struct passwd *pw;
-
- if ((pw = getpwnam(name)) == NULL)
- return(UID_MAX);
- return(pw->pw_uid);
-}
-/* $OpenBSD: glob.h,v 1.8 2014/11/24 20:01:43 millert Exp $ */
+/* $OpenBSD: glob.h,v 1.9 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: glob.h,v 1.4 1996/06/08 19:48:25 christos Exp $ */
/*
char mailname[PATHSIZE]; /* Name of current file */
char prevfile[PATHSIZE]; /* Name of previous file */
char *homedir; /* Path name of home directory */
-char *myname; /* My login name */
+const char
+ *myname; /* My login name */
off_t mailsize; /* Size of system mailbox */
int lexnumber; /* Number of TNUMBER from scan() */
char lexstring[STRINGLEN]; /* String from TSTRING, scan() */
-/* $OpenBSD: lex.c,v 1.39 2015/10/16 17:56:07 mmcc Exp $ */
+/* $OpenBSD: lex.c,v 1.40 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
int i, fd;
struct stat stb;
char isedit = *name != '%';
- char *who = name[1] ? name + 1 : myname;
+ const char *who = name[1] ? name + 1 : myname;
char tempname[PATHSIZE];
static int shudclob;
-/* $OpenBSD: names.c,v 1.23 2015/10/16 17:56:07 mmcc Exp $ */
+/* $OpenBSD: names.c,v 1.24 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */
/*
* Delete the given name from a namelist.
*/
struct name *
-delname(struct name *np, char *name)
+delname(struct name *np, const char *name)
{
struct name *p;
-/* $OpenBSD: temp.c,v 1.17 2016/07/28 21:37:45 tedu Exp $ */
+/* $OpenBSD: temp.c,v 1.18 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: temp.c,v 1.5 1996/06/08 19:48:42 christos Exp $ */
/*
*/
#include "rcv.h"
+#include <pwd.h>
#include "extern.h"
/*
* do a spreserve() after us.
*/
if (myname != NULL) {
- if (getuserid(myname) == UID_MAX)
+ uid_t uid;
+
+ if (uid_from_user(myname, &uid) == -1)
errx(1, "\"%s\" is not a user of this system", myname);
} else {
- if ((cp = username()) == NULL) {
+ if ((myname = username()) == NULL) {
myname = "nobody";
if (rcvmode)
exit(1);
} else
- myname = savestr(cp);
+ myname = savestr(myname);
}
if ((cp = getenv("HOME")) == NULL || *cp == '\0' ||
strlen(cp) >= PATHSIZE)
-/* $OpenBSD: v7.local.c,v 1.17 2016/07/19 06:43:27 deraadt Exp $ */
+/* $OpenBSD: v7.local.c,v 1.18 2018/09/16 02:38:57 millert Exp $ */
/* $NetBSD: v7.local.c,v 1.8 1997/05/13 06:15:58 mikel Exp $ */
/*
#include "rcv.h"
#include <stdlib.h>
#include <fcntl.h>
+#include <pwd.h>
#include "extern.h"
/*
* mail is queued).
*/
void
-findmail(char *user, char *buf, int buflen)
+findmail(const char *user, char *buf, int buflen)
{
char *mbox;
struct stat sb;
/*
* Discover user login name.
*/
-char *
+const char *
username(void)
{
- char *np;
+ const char *np;
uid_t uid;
if ((np = getenv("USER")) != NULL)
return(np);
if ((np = getenv("LOGNAME")) != NULL)
return(np);
- if ((np = getname(uid = getuid())) != NULL)
+ if ((np = user_from_uid(uid = getuid(), 1)) != NULL)
return(np);
if ((np = getlogin()) != NULL)
return(np);
- printf("Cannot associate a name with uid %u\n", (unsigned)uid);
+ printf("Cannot associate a name with uid %u\n", uid);
return(NULL);
}