Commit dc990351 authored by Michael Smith's avatar Michael Smith

Use remove() then rename() only on win32 - where it's required.

Don't use it on unix systems, which don't need it, and where doing 
_only_ rename() preserves atomicity. 

svn path=/icecast/trunk/icecast/; revision=6625
parent d11f7778
...@@ -366,6 +366,7 @@ int auth_htpasswd_deleteuser(auth_t *auth, char *username) ...@@ -366,6 +366,7 @@ int auth_htpasswd_deleteuser(auth_t *auth, char *username)
fclose(passwdfile); fclose(passwdfile);
/* Now move the contents of the tmp file to the original */ /* Now move the contents of the tmp file to the original */
#ifdef _WIN32
/* Windows won't let us rename a file if the destination file /* Windows won't let us rename a file if the destination file
exists...so, lets remove the original first */ exists...so, lets remove the original first */
if (remove(state->filename) != 0) { if (remove(state->filename) != 0) {
...@@ -373,11 +374,14 @@ int auth_htpasswd_deleteuser(auth_t *auth, char *username) ...@@ -373,11 +374,14 @@ int auth_htpasswd_deleteuser(auth_t *auth, char *username)
tmpfile, state->filename, strerror(errno)); tmpfile, state->filename, strerror(errno));
} }
else { else {
#endif
if (rename(tmpfile, state->filename) != 0) { if (rename(tmpfile, state->filename) != 0) {
ERROR3("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", ERROR3("Problem moving temp authentication file to original \"%s\" - \"%s\": %s",
tmpfile, state->filename, strerror(errno)); tmpfile, state->filename, strerror(errno));
} }
#ifdef _WIN32
} }
#endif
free(tmpfile); free(tmpfile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment