[PATCH 3/4] s3fs-popt: Add function to burn the commandline password.
Jeremy Allison
jra at samba.org
Tue Oct 30 12:14:09 MDT 2012
On Tue, Oct 30, 2012 at 10:25:44AM -0700, Jeremy Allison wrote:
> On Mon, Oct 29, 2012 at 09:12:15PM +0100, Andreas Schneider wrote:
> >
> > Signed-off-by: Andreas Schneider <asn at samba.org>
> > + * @brief Burn the commandline password.
> > + *
> > + * This function removes the password from the command line so we
> > + * don't leak the password e.g. in 'ps aux'.
> > + *
> > + * It should be called after processing the options and you should pass down
> > + * argv from main().
> > + *
> > + * @param[in] argc The number of arguments.
> > + *
> > + * @param[in] argv[] The argument array we will find the array.
> > + */
> > +void popt_burn_cmdline_password(int argc, char *argv[])
> > +{
> > + bool found = false;
> > + char *p = NULL;
> > + int i;
> > +
> > + for (i = 0; i < argc; i++) {
> > + p = argv[i];
> > + if (strncmp(p, "-U", 2) == 0) {
> > + found = true;
> > + }
> > +
> > + if (found && strlen(p) > 2) {
> > + break;
> > + }
> > + }
> > +
> > + if (p == NULL) {
> > + return;
> > + }
> > +
> > + p = strchr(p, '%');
>
> Sorry - have to NAK on this.
>
> strchr must be strchr_m to deal with MB character sets
> on the command line. Check out the other usages of
> strchr_m in source3/lib/popt_common.c.
>
> Fix that and I'll re-review.
FYI. The first 2 patches are fine, I've pushed them
to autobuild.
Cheers,
Jeremy
More information about the samba-technical
mailing list