- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# rpmio/getpass.c

Go to the documentation of this file.

    00001
    00005 #include "system.h"
    00006 #include "rpmio.h"
    00007 #if defined(HAVE_KEYUTILS_H)
    00008 #include <argv.h>
    00009 #include <keyutils.h>
    00010 #endif
    00011 #include "debug.h"
    00012
    00013 char * _GetPass(const char * prompt)
    00014 {
    00015     char * pw;
    00016
    00017 /*@-unrecog@*/
    00018     pw = getpass( prompt ? prompt : "" );
    00019 /*@=unrecog@*/
    00020
    00021 #if defined(HAVE_KEYUTILS_H)
    00022     if (pw && *pw) {
    00023         size_t npw = strlen(pw);
    00024         key_serial_t keyring = KEY_SPEC_PROCESS_KEYRING;
    00025         (void) add_key("user", "rpm:passwd", pw, npw, keyring);
    00026         (void) memset(pw, 0, npw);      /* burn the password */
    00027         pw = "@u user rpm:passwd";
    00028     }
    00029 #endif
    00030
    00031 assert(pw != NULL);
    00032 /*@-observertrans -statictrans@*/
    00033     return pw;
    00034 /*@=observertrans =statictrans@*/
    00035 }
    00036
    00037 char * _RequestPass(/*@unused@*/ const char * prompt)
    00038 {
    00039 /*@relnull@*/
    00040     static char * password = NULL;
    00041 #if defined(HAVE_KEYUTILS_H)
    00042     const char * foo = "user rpm:yyyy spoon";
    00043     ARGV_t av = NULL;
    00044     int xx = argvSplit(&av, foo, NULL);
    00045     key_serial_t dest = 0;
    00046     key_serial_t key = 0;
    00047
    00048     if (password) {
    00049         free(password);
    00050         password = NULL;
    00051     }
    00052 assert(av != NULL);
    00053 assert(av[0] != NULL);
    00054 assert(av[1] != NULL);
    00055 assert(av[2] != NULL);
    00056     key = request_key(av[0], av[1], av[2], dest);
    00057
    00058 /*@-nullstate@*/        /* XXX *password may be null. */
    00059     xx = keyctl_read_alloc(key, (void *)&password);
    00060 /*@=nullstate@*/
    00061 assert(password != NULL);
    00062 #endif
    00063
    00064 /*@-statictrans@*/
    00065     return password;
    00066 /*@=statictrans@*/
    00067 }
    00068
    00069 /*@-redecl@*/
    00070 char * (*Getpass) (const char * prompt) = _GetPass;
    00071 /*@=redecl@*/