Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/db: remove deprecated implementation of db_set_login() and replace it with that of db_set_login2() #4308

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions db/db.login/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}

if (db_set_login2(driver->answer, database->answer, user->answer,
password->answer, host->answer, port->answer,
G_get_overwrite()) == DB_FAILED) {
if (db_set_login(driver->answer, database->answer, user->answer,
password->answer, host->answer, port->answer,
G_get_overwrite()) == DB_FAILED) {
G_fatal_error(_("Unable to set user/password"));
}

Expand Down
3 changes: 2 additions & 1 deletion include/grass/defs/dbmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ const char *db_whoami(void);
void db_zero(void *, int);
void db_zero_string(dbString *);
unsigned int db_sizeof_string(const dbString *);
int db_set_login(const char *, const char *, const char *, const char *);
int db_set_login(const char *, const char *, const char *, const char *,
const char *, const char *, int);
int db_set_login2(const char *, const char *, const char *, const char *,
const char *, const char *, int);
int db_get_login(const char *, const char *, const char **, const char **);
Expand Down
21 changes: 11 additions & 10 deletions lib/db/dbmi_base/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
fprintf(fd, "|%s", login->data[i].user);

if (login->data[i].password)
fprintf(fd, "|%s", login->data[i].password);

Check failure

Code scanning / CodeQL

Cleartext storage of sensitive information in file High

This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
This write into file 'fd' may contain unencrypted data from
this source.
.
}
if (login->data[i].host)
fprintf(fd, "|%s", login->data[i].host);
Expand Down Expand Up @@ -253,22 +253,23 @@
/*!
\brief Set login parameters for driver/database

\deprecated Use db_set_login2() instead.

\todo: GRASS 8: to be replaced by db_set_login2().

\param driver driver name
\param database database name
\param user user name
\param password password string
\param host host name
\param port
\param overwrite TRUE to overwrite existing connections

\return DB_OK on success
\return DB_FAILED on failure
*/
int db_set_login(const char *driver, const char *database, const char *user,
const char *password)
int db_set_login2(const char *driver, const char *database, const char *user,
const char *password, const char *host, const char *port,
int overwrite)
{
return set_login(driver, database, user, password, NULL, NULL, FALSE);
return db_set_login(driver, database, user, password, host, port,
overwrite);
}

/*!
Expand All @@ -285,9 +286,9 @@
\return DB_OK on success
\return DB_FAILED on failure
*/
int db_set_login2(const char *driver, const char *database, const char *user,
const char *password, const char *host, const char *port,
int overwrite)
int db_set_login(const char *driver, const char *database, const char *user,
const char *password, const char *host, const char *port,
int overwrite)
{
return set_login(driver, database, user, password, host, port, overwrite);
}
Expand Down
Loading