Fixed an issue where pg_md5 and pg_enc would not update the password file if a file...
authorBo Peng <pengbo@sraoss.co.jp>
Mon, 9 Dec 2024 07:56:13 +0000 (16:56 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Mon, 9 Dec 2024 08:12:55 +0000 (17:12 +0900)
This issue is reported by Sadhuprasad Patro.

src/tools/pgenc/pg_enc.c
src/tools/pgmd5/pg_md5.c

index e39ddafc1f13c079c7500783c50273a337b68b46..d548fd6df662d813025c1200064bb27b361dd883 100644 (file)
@@ -412,16 +412,23 @@ update_pool_passwd(char *conf_file, char *username, char *password, char *key)
                fprintf(stderr, "pool_init_config() failed\n\n");
                exit(EXIT_FAILURE);
        }
-       if (pool_get_config(conf_file, CFGCXT_RELOAD) == false)
+       if (pool_get_config(conf_file, CFGCXT_INIT) == false)
        {
                fprintf(stderr, "Unable to get configuration. Exiting...\n\n");
                exit(EXIT_FAILURE);
        }
 
-       strlcpy(dirnamebuf, conf_file, sizeof(dirnamebuf));
-       dirp = dirname(dirnamebuf);
-       snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s",
-                        dirp, pool_config->pool_passwd);
+       if (pool_config->pool_passwd[0] != '/')
+       {
+               strlcpy(dirnamebuf, conf_file, sizeof(dirnamebuf));
+               dirp = dirname(dirnamebuf);
+               snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s",
+                                dirp, pool_config->pool_passwd);
+       }
+       else
+               strlcpy(pool_passwd, pool_config->pool_passwd,
+                               sizeof(pool_passwd));
+
        pool_init_pool_passwd(pool_passwd, POOL_PASSWD_RW);
 
        if (username == NULL || strlen(username) == 0)
index 25d36a4d271eb6ca1639bb38feb79e675df1debd..e7d002757b7371f912e39bdfccf6b61e344a8e40 100644 (file)
@@ -308,16 +308,23 @@ update_pool_passwd(char *conf_file, char *username, char *password)
                fprintf(stderr, "pool_init_config() failed\n\n");
                exit(EXIT_FAILURE);
        }
-       if (pool_get_config(conf_file, CFGCXT_RELOAD) == false)
+       if (pool_get_config(conf_file, CFGCXT_INIT) == false)
        {
                fprintf(stderr, "Unable to get configuration. Exiting...\n\n");
                exit(EXIT_FAILURE);
        }
 
-       strlcpy(dirnamebuf, conf_file, sizeof(dirnamebuf));
-       dirp = dirname(dirnamebuf);
-       snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s",
-                        dirp, pool_config->pool_passwd);
+       if (pool_config->pool_passwd[0] != '/')
+       {
+               strlcpy(dirnamebuf, conf_file, sizeof(dirnamebuf));
+               dirp = dirname(dirnamebuf);
+               snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s",
+                               dirp, pool_config->pool_passwd);
+       }
+       else
+               strlcpy(pool_passwd, pool_config->pool_passwd,
+                                               sizeof(pool_passwd));
+
        pool_init_pool_passwd(pool_passwd, POOL_PASSWD_RW);
 
        if (strlen(username))