diff options
author | Jeremy Allison <jra@samba.org> | 2000-03-02 03:04:26 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-03-02 03:04:26 +0000 |
commit | 5eae8c7b0225aa4f4818edc1becbf399bb4cd42e (patch) | |
tree | 3f365fec197b3e8645aed7af10bb7a99f52f84a0 | |
parent | ea1c3cc23dc7769908e5bb3d56ba731f03ddbcd1 (diff) | |
download | samba-5eae8c7b0225aa4f4818edc1becbf399bb4cd42e.tar.gz samba-5eae8c7b0225aa4f4818edc1becbf399bb4cd42e.tar.bz2 samba-5eae8c7b0225aa4f4818edc1becbf399bb4cd42e.zip |
Tidied up fchown code, error reporting.
Jeremy.
(This used to be commit 8e3239440dee6c6f50d26b70f7db46bef2a87a2d)
-rw-r--r-- | source3/passdb/smbpass.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index 701d796c56..7aad048339 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -116,14 +116,14 @@ static void *startsmbfilepwent_internal(const char *pfile, enum pwf_access_type DEBUG(0, ("startsmbfilepwent_internal: unable to stat file %s. Error was %s\n", pfile, strerror(errno))); pw_file_unlock(fileno(fp), lock_depth); fclose(fp); - return False; + return NULL; } if (sys_fstat(fileno(fp),&sbuf2) != 0) { DEBUG(0, ("startsmbfilepwent_internal: unable to fstat file %s. Error was %s\n", pfile, strerror(errno))); pw_file_unlock(fileno(fp), lock_depth); fclose(fp); - return False; + return NULL; } if( sbuf1.st_ino == sbuf2.st_ino) { @@ -149,7 +149,13 @@ static void *startsmbfilepwent_internal(const char *pfile, enum pwf_access_type setvbuf(fp, (char *)NULL, _IOFBF, 1024); /* Make sure it is only rw by the owner */ - chmod(pfile, 0600); + if(fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1) { + DEBUG(0, ("startsmbfilepwent_internal: failed to set 0600 permissions on password file %s. \ +Error was %s\n.", pfile, strerror(errno) )); + pw_file_unlock(fileno(fp), lock_depth); + fclose(fp); + return NULL; + } /* We have a lock on the file. */ return (void *)fp; |