Whats the mechanism behind sudo that stores the password for all subsequent calls to sudo?

  • In Debian, it's under /var/lib/sudo/ts/<username>, with permissions 0600. At least, if you delete that file, all that user's terminals have to enter the password again. On other systems it might be stored elsewhere. – marinus Mar 26 '16 at 14:11
  • 3
    It's not storing your password, just a time stamp file – Jeff Schaller Mar 26 '16 at 14:18

To clarify, sudo uses a timestamp cache file (configured at build time with --with-rundir) and stores a timestamp entry (see ts_write() with it's struct timestamp argument) to the file. That struct is defined

struct ts_cookie {
    char *fname;
    int fd;
    pid_t sid;
    bool locked;
    off_t pos;
    struct timestamp_entry key;

where fname is set as the path to the cache file (and not the user's password) -- see timestamp_open() where it uses asprintf(&fname, "%s/%s", def_timestampdir, user) to set fname.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.