diff options
author | Jeremy Allison <jra@samba.org> | 2007-11-13 12:51:31 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-11-13 12:51:31 -0800 |
commit | 052efa9a33d7a9a3b9ae9b038f6b3943c85c4bfc (patch) | |
tree | fcfd470f6db1ac8262e76f1bd29af2db5e2b4aee /source3/smbd/utmp.c | |
parent | b2f942cfe2672fac9449ce730b18cf7b5fc6e1f0 (diff) | |
download | samba-052efa9a33d7a9a3b9ae9b038f6b3943c85c4bfc.tar.gz samba-052efa9a33d7a9a3b9ae9b038f6b3943c85c4bfc.tar.bz2 samba-052efa9a33d7a9a3b9ae9b038f6b3943c85c4bfc.zip |
Remove last pstring from smbd/*.c
Jeremy.
(This used to be commit f1680bada913af4eaf5c0d686983018d6c8b3e5f)
Diffstat (limited to 'source3/smbd/utmp.c')
-rw-r--r-- | source3/smbd/utmp.c | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c index c2908e33cc..e82bbea3b3 100644 --- a/source3/smbd/utmp.c +++ b/source3/smbd/utmp.c @@ -207,30 +207,36 @@ static const char *ll_pathname = * utmp{,x}: try "utmp dir", then default (a define) * wtmp{,x}: try "wtmp dir", then "utmp dir", then default (a define) */ -static void uw_pathname(pstring fname, const char *uw_name, const char *uw_default) +static char *uw_pathname(TALLOC_CTX *ctx, + const char *uw_name, + const char *uw_default) { - pstring dirname; - - pstrcpy(dirname, ""); + char *dirname = NULL; /* For w-files, first look for explicit "wtmp dir" */ if (uw_name[0] == 'w') { - pstrcpy(dirname,lp_wtmpdir()); + dirname = talloc_strdup(ctx, lp_wtmpdir()); + if (!dirname) { + return NULL; + } trim_char(dirname,'\0','/'); } /* For u-files and non-explicit w-dir, look for "utmp dir" */ - if (dirname == 0 || strlen(dirname) == 0) { - pstrcpy(dirname,lp_utmpdir()); + if (!dirname == 0 || strlen(dirname) == 0) { + dirname = talloc_strdup(ctx, lp_utmpdir()); + if (!dirname) { + return NULL; + } trim_char(dirname,'\0','/'); } /* If explicit directory above, use it */ - if (dirname != 0 && strlen(dirname) != 0) { - pstrcpy(fname, dirname); - pstrcat(fname, "/"); - pstrcat(fname, uw_name); - return; + if (dirname && strlen(dirname) != 0) { + return talloc_asprintf(ctx, + "%s/%s", + dirname, + uw_name); } /* No explicit directory: attempt to use default paths */ @@ -240,16 +246,15 @@ static void uw_pathname(pstring fname, const char *uw_name, const char *uw_defau */ DEBUG(2,("uw_pathname: unable to determine pathname\n")); } - pstrcpy(fname, uw_default); + return talloc_strdup(ctx, uw_default); } #ifndef HAVE_PUTUTLINE - /**************************************************************************** Update utmp file directly. No subroutine interface: probably a BSD system. ****************************************************************************/ -static void pututline_my(pstring uname, struct utmp *u, bool claim) +static void pututline_my(const char *uname, struct utmp *u, bool claim) { DEBUG(1,("pututline_my: not yet implemented\n")); /* BSD implementor: may want to consider (or not) adjusting "lastlog" */ @@ -263,7 +268,7 @@ static void pututline_my(pstring uname, struct utmp *u, bool claim) Credit: Michail Vidiassov <master@iaas.msu.ru> ****************************************************************************/ -static void updwtmp_my(pstring wname, struct utmp *u, bool claim) +static void updwtmp_my(const char *wname, struct utmp *u, bool claim) { int fd; struct stat buf; @@ -308,12 +313,16 @@ static void updwtmp_my(pstring wname, struct utmp *u, bool claim) static void utmp_nox_update(struct utmp *u, bool claim) { - pstring uname, wname; + char *uname = NULL; + char *wname = NULL; #if defined(PUTUTLINE_RETURNS_UTMP) struct utmp *urc; #endif /* PUTUTLINE_RETURNS_UTMP */ - uw_pathname(uname, "utmp", ut_pathname); + uname = uw_pathname(talloc_tos(), "utmp", ut_pathname); + if (!uname) { + return; + } DEBUG(2,("utmp_nox_update: uname:%s\n", uname)); #ifdef HAVE_PUTUTLINE @@ -341,7 +350,10 @@ static void utmp_nox_update(struct utmp *u, bool claim) } #endif /* HAVE_PUTUTLINE */ - uw_pathname(wname, "wtmp", wt_pathname); + wname = uw_pathname(talloc_tos(), "wtmp", wt_pathname); + if (!wname) { + return; + } DEBUG(2,("utmp_nox_update: wname:%s\n", wname)); if (strlen(wname) != 0) { #ifdef HAVE_UPDWTMP @@ -398,7 +410,8 @@ static void sys_utmp_update(struct utmp *u, const char *hostname, bool claim) DEBUG(1,("utmp_update: have utmpx.h but no getutmpx() function\n")); utmp_nox_update(u, claim); #else - pstring uname, wname; + char *uname = NULL; + char *wname = NULL; struct utmpx ux, *uxrc; getutmpx(u, &ux); @@ -413,9 +426,12 @@ static void sys_utmp_update(struct utmp *u, const char *hostname, bool claim) utmp_strcpy(ux.ut_host, hostname, sizeof(ux.ut_host)); #endif - uw_pathname(uname, "utmpx", ux_pathname); - uw_pathname(wname, "wtmpx", wx_pathname); - DEBUG(2,("utmp_update: uname:%s wname:%s\n", uname, wname)); + uname = uw_pathname(talloc_tos(), "utmpx", ux_pathname); + wname = uw_pathname(talloc_tos(), "wtmpx", wx_pathname); + if (uname && wname) { + DEBUG(2,("utmp_update: uname:%s wname:%s\n", uname, wname)); + } + /* * Check for either uname or wname being empty. * Some systems, such as Redhat 6, have a "utmpx.h" which doesn't @@ -423,7 +439,7 @@ static void sys_utmp_update(struct utmp *u, const char *hostname, bool claim) * Also, our local installation has not provided an override. * Drop to non-x method. (E.g. RH6 has good defaults in "utmp.h".) */ - if ((strlen(uname) == 0) || (strlen(wname) == 0)) { + if (!uname || !wname || (strlen(uname) == 0) || (strlen(wname) == 0)) { utmp_nox_update(u, claim); } else { utmpxname(uname); |