summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/modem.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp
index 7b2e2a3..17ada9b 100644
--- a/noncore/settings/networksettings/ppp/modem.cpp
+++ b/noncore/settings/networksettings/ppp/modem.cpp
@@ -747,50 +747,52 @@ bool Modem::createAuthFile(Auth method, const char *username, const char *passwo
if(regexec(&preg, line, 0, 0L, 0) == 0)
continue;
fputs(line, fout);
}
fclose(fin);
}
// append user/pass pair
fprintf(fout, "\"%s\"\t*\t\"%s\"\n", username, password);
fclose(fout);
}
// restore umask
umask(old_umask);
// free memory allocated by regcomp
regfree(&preg);
if(!(oldName = authFile(method, Old)))
return false;
// delete old file if any
unlink(oldName);
- rename(authfile, oldName);
- rename(newName, authfile);
+ if (rename(authfile, oldName) == -1)
+ return false;
+ if (rename(newName, authfile) == -1)
+ return false;
return true;
}
bool Modem::removeAuthFile(Auth method) {
const char *authfile, *oldName;
if(!(authfile = authFile(method)))
return false;
if(!(oldName = authFile(method, Old)))
return false;
if(access(oldName, F_OK) == 0) {
unlink(authfile);
return (rename(oldName, authfile) == 0);
} else
return false;
}
bool Modem::setSecret(int method, const char* name, const char* password)
{