Pelo código-fonte , lofiadm
usa pkcs11_get_pass
de libcryptoutil.so
para obter a senha:
864 rv = C_OpenSession(cipher->slot, CKF_SERIAL_SESSION, NULL, NULL, &sess);
865 if (rv != CKR_OK)
866 goto cleanup;
867
868 /* get user passphrase with 8 byte minimum */
869 if (pkcs11_get_pass(NULL, &pass, &passlen, MIN_PASSLEN, B_TRUE) < 0) {
870 die(gettext("passphrases do not match\n"));
871 }
872
873 /*
874 * salt should not be NULL, or else pkcs11_PasswdToKey() will
875 * complain about CKR_MECHANISM_PARAM_INVALID; the following is
876 * to make up for not having a salt until a proper one is used
877 */
878 salt = pass;
879 saltlen = passlen;
880
881 klen = cipher->max_keysize;
882 rv = pkcs11_PasswdToKey(sess, pass, passlen, salt, saltlen, ktype,
883 cipher->max_keysize, &kvalue, &klen);
E pkcs11_get_pass
usa getpassphrase()
:
72 if (token_name != NULL)
73 (void) snprintf(prompt, sizeof (prompt), DEFAULT_TOKEN_PROMPT,
74 token_name);
75 else
76 (void) snprintf(prompt, sizeof (prompt), DEFAULT_USER_PROMPT);
77
78 for (tries = MAX_PASS_TRIES; tries > 0; tries--) {
79 tmpbuf = getpassphrase(prompt);
80 if (tmpbuf == NULL)
81 return (-1);
82
83 if (strnlen(tmpbuf, min_psize) >= min_psize)
84 break;
85
86 if (token_name != NULL)
87 (void) printf(DEFAULT_TOKEN_MINSIZE, min_psize);
88 else
89 (void) printf(DEFAULT_USER_MINSIZE, min_psize);
90 }
91 if (tries == 0) {
92 (void) printf(gettext("Exceeded number of attempts.\n"));
93 return (-1);
94 }
A página de manual de getpassphrase()
diz não funcionará sem acesso ao terminal:
The getpass() function opens the process's controlling terminal, writes to that device the null-terminated string prompt, disables echoing, reads a string of characters up to the next newline character or EOF, restores the terminal state and closes the terminal.
The getpassphrase() function is identical to getpass(), except that it reads and returns a string of up to 257 characters in length.
...
ENXIO
The process does not have a controlling terminal.
Portanto, parece que não há uma maneira fácil de inserir scripts de senha.