mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-28 20:58:31 +00:00
Changed API: function mg_modify_passwords_file(). Instead of passing context, a domain name is passed, thus making this function completely mongoose-agnostic.
This commit is contained in:
1 parent
27ccf416c1
commit
29716fa22e
3 files changed
+7
-25
No files matched your search
+2
-5
@@ -2226,16 +2226,14 @@ static int is_authorized_for_put(struct mg_connection *conn) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mg_modify_passwords_file(struct mg_context *ctx, const char *fname,
|
||||
int mg_modify_passwords_file(const char *fname, const char *domain,
|
||||
const char *user, const char *pass) {
|
||||
int found;
|
||||
char line[512], u[512], d[512], ha1[33], tmp[PATH_MAX];
|
||||
const char *domain;
|
||||
FILE *fp, *fp2;
|
||||
|
||||
found = 0;
|
||||
fp = fp2 = NULL;
|
||||
domain = ctx->config[AUTHENTICATION_DOMAIN];
|
||||
|
||||
// Regard empty password as no password - remove user record.
|
||||
if (pass[0] == '\0') {
|
||||
@@ -2251,10 +2249,9 @@ int mg_modify_passwords_file(struct mg_context *ctx, const char *fname,
|
||||
|
||||
// Open the given file and temporary file
|
||||
if ((fp = mg_fopen(fname, "r")) == NULL) {
|
||||
cry(fc(ctx), "Cannot open %s: %s", fname, strerror(errno));
|
||||
return 0;
|
||||
} else if ((fp2 = mg_fopen(tmp, "w+")) == NULL) {
|
||||
cry(fc(ctx), "Cannot open %s: %s", tmp, strerror(errno));
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user