Menu

#12 Prevent password in output

v1.0 (example)
open
nobody
password (1)
3
2024-03-26
2024-03-25
Robert Pena
No

Hi, I am trying to prevent the password from being outputted using the following commands.

hdparm --user-master m -q --security-erase password drivePath

I also added the -q switch and that doesn't seem to change anything. I would like to prevent the passwood from being output in logs if possible. Thanks.

Discussion

  • Robert Pena

    Robert Pena - 2024-03-26

    I get this output even when using -q (quite) when setting the SATA drive password or similar when issuing the erase command.

    Issuing SECURITY_SET_PASS command, password=...

     
  • Mark Lord

    Mark Lord - 2024-03-26
    --- hdparm-9.65/hdparm.c        2022-09-06 13:02:56.000000000 -0400
    +++ hdparm/hdparm.c     2024-03-25 20:30:28.873285139 -0400
    @@ -2,7 +2,7 @@
      * hdparm.c - Command line interface to get/set hard disk parameters.
      *          - by Mark Lord (C) 1994-2022 -- freely distributable.
      */
    -#define HDPARM_VERSION "v9.65"
    +#define HDPARM_VERSION "v9.65+"
    
     #define _LARGEFILE64_SOURCE /*for lseek64*/
     #define _BSD_SOURCE    /* for strtoll() */
    @@ -3040,16 +3040,18 @@ static void get_security_password (int h
            } else if (!handle_NULL || strcmp(argp, "NULL")) {
                    strcpy(security_password, argp);
            }
    -       printf("security_password:");
    -       if (!binary_passwd) {
    -               printf(" \"%s\"\n", security_password);
    -       } else {
    -               unsigned int i;
    -               for (i = 0; i < maxlen; ++i) {
    -                       unsigned char c = security_password[i];
    -                       printf(" %02x", c);
    +       if (!quiet) {
    +               printf("security_password:");
    +               if (!binary_passwd) {
    +                       printf(" \"%s\"\n", security_password);
    +               } else {
    +                       unsigned int i;
    +                       for (i = 0; i < maxlen; ++i) {
    +                               unsigned char c = security_password[i];
    +                               printf(" %02x", c);
    +                       }
    +                       putchar('\n');
                    }
    -               putchar('\n');
            }
            while (*argp)
                    ++argp;
    @@ -3468,7 +3470,7 @@ int main (int _argc, char **_argv)
                                    case GET_SET_PARM('n',"ignore-write-errors",nowerr,0,1);
                                    case              'N': get_set_max_sectors_parms(); break;
                                    case     SET_PARM('P',"prefetch",prefetch,0,255);
    -                               case              'q': quiet = 1; noisy = 0; break;
    +                               case              'q': quiet = 1; noisy = 0; --num_flags_processed; break;
                                    case GET_SET_PARM('Q',"queue-depth",dma_q,0,1024);
                                    case     SET_PARM('s',"powerup-in-standby",powerup_in_standby,0,1);
                                    case     SET_PARM('S',"standby-interval",standby,0,255);
    
     
  • Mark Lord

    Mark Lord - 2024-03-26

    Try that and report back.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.