1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

lib/cmdline: Return if the commandline was redacted in samba_cmdline_burn()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15289

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2023-07-21 15:27:00 +12:00
parent 0da6cc7105
commit 848fea1a01
2 changed files with 8 additions and 3 deletions

View File

@ -135,8 +135,9 @@ void samba_cmdline_set_machine_account_fn(
cli_credentials_set_machine_account_fn = fn; cli_credentials_set_machine_account_fn = fn;
} }
void samba_cmdline_burn(int argc, char *argv[]) bool samba_cmdline_burn(int argc, char *argv[])
{ {
bool burnt = false;
bool found = false; bool found = false;
bool is_user = false; bool is_user = false;
char *p = NULL; char *p = NULL;
@ -146,7 +147,7 @@ void samba_cmdline_burn(int argc, char *argv[])
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
p = argv[i]; p = argv[i];
if (p == NULL) { if (p == NULL) {
return; return false;
} }
if (strncmp(p, "-U", 2) == 0) { if (strncmp(p, "-U", 2) == 0) {
@ -181,8 +182,10 @@ void samba_cmdline_burn(int argc, char *argv[])
memset_s(p, strlen(p), '\0', strlen(p)); memset_s(p, strlen(p), '\0', strlen(p));
found = false; found = false;
is_user = false; is_user = false;
burnt = true;
} }
} }
return burnt;
} }
static bool is_popt_table_end(const struct poptOption *o) static bool is_popt_table_end(const struct poptOption *o)

View File

@ -147,8 +147,10 @@ void samba_cmdline_set_machine_account_fn(
* @param[in] argc The number of arguments. * @param[in] argc The number of arguments.
* *
* @param[in] argv[] The argument array we should remove secrets from. * @param[in] argv[] The argument array we should remove secrets from.
*
* @return true if a password was removed, false otherwise.
*/ */
void samba_cmdline_burn(int argc, char *argv[]); bool samba_cmdline_burn(int argc, char *argv[]);
/** /**
* @brief Sanity check the command line options. * @brief Sanity check the command line options.