summaryrefslogtreecommitdiff
path: root/source4/auth/credentials/credentials_files.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/auth/credentials/credentials_files.c')
-rw-r--r--source4/auth/credentials/credentials_files.c131
1 files changed, 0 insertions, 131 deletions
diff --git a/source4/auth/credentials/credentials_files.c b/source4/auth/credentials/credentials_files.c
index e1990a8713..4a9ccf5358 100644
--- a/source4/auth/credentials/credentials_files.c
+++ b/source4/auth/credentials/credentials_files.c
@@ -36,137 +36,6 @@
#include "dsdb/samdb/samdb.h"
/**
- * Read a file descriptor, and parse it for a password (eg from a file or stdin)
- *
- * @param credentials Credentials structure on which to set the password
- * @param fd open file descriptor to read the password from
- * @param obtained This enum describes how 'specified' this password is
- */
-
-_PUBLIC_ bool cli_credentials_parse_password_fd(struct cli_credentials *credentials,
- int fd, enum credentials_obtained obtained)
-{
- char *p;
- char pass[128];
-
- for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */
- p && p - pass < sizeof(pass);) {
- switch (read(fd, p, 1)) {
- case 1:
- if (*p != '\n' && *p != '\0') {
- *++p = '\0'; /* advance p, and null-terminate pass */
- break;
- }
- /* fall through */
- case 0:
- if (p - pass) {
- *p = '\0'; /* null-terminate it, just in case... */
- p = NULL; /* then force the loop condition to become false */
- break;
- } else {
- fprintf(stderr, "Error reading password from file descriptor %d: %s\n", fd, "empty password\n");
- return false;
- }
-
- default:
- fprintf(stderr, "Error reading password from file descriptor %d: %s\n",
- fd, strerror(errno));
- return false;
- }
- }
-
- cli_credentials_set_password(credentials, pass, obtained);
- return true;
-}
-
-/**
- * Read a named file, and parse it for a password
- *
- * @param credentials Credentials structure on which to set the password
- * @param file a named file to read the password from
- * @param obtained This enum describes how 'specified' this password is
- */
-
-_PUBLIC_ bool cli_credentials_parse_password_file(struct cli_credentials *credentials, const char *file, enum credentials_obtained obtained)
-{
- int fd = open(file, O_RDONLY, 0);
- bool ret;
-
- if (fd < 0) {
- fprintf(stderr, "Error opening password file %s: %s\n",
- file, strerror(errno));
- return false;
- }
-
- ret = cli_credentials_parse_password_fd(credentials, fd, obtained);
-
- close(fd);
-
- return ret;
-}
-
-/**
- * Read a named file, and parse it for username, domain, realm and password
- *
- * @param credentials Credentials structure on which to set the password
- * @param file a named file to read the details from
- * @param obtained This enum describes how 'specified' this password is
- */
-
-_PUBLIC_ bool cli_credentials_parse_file(struct cli_credentials *cred, const char *file, enum credentials_obtained obtained)
-{
- uint16_t len = 0;
- char *ptr, *val, *param;
- char **lines;
- int i, numlines;
-
- lines = file_lines_load(file, &numlines, 0, NULL);
-
- if (lines == NULL)
- {
- /* fail if we can't open the credentials file */
- d_printf("ERROR: Unable to open credentials file!\n");
- return false;
- }
-
- for (i = 0; i < numlines; i++) {
- len = strlen(lines[i]);
-
- if (len == 0)
- continue;
-
- /* break up the line into parameter & value.
- * will need to eat a little whitespace possibly */
- param = lines[i];
- if (!(ptr = strchr_m (lines[i], '=')))
- continue;
-
- val = ptr+1;
- *ptr = '\0';
-
- /* eat leading white space */
- while ((*val!='\0') && ((*val==' ') || (*val=='\t')))
- val++;
-
- if (strwicmp("password", param) == 0) {
- cli_credentials_set_password(cred, val, obtained);
- } else if (strwicmp("username", param) == 0) {
- cli_credentials_set_username(cred, val, obtained);
- } else if (strwicmp("domain", param) == 0) {
- cli_credentials_set_domain(cred, val, obtained);
- } else if (strwicmp("realm", param) == 0) {
- cli_credentials_set_realm(cred, val, obtained);
- }
- memset(lines[i], 0, len);
- }
-
- talloc_free(lines);
-
- return true;
-}
-
-
-/**
* Fill in credentials for the machine trust account, from the secrets database.
*
* @param cred Credentials structure to fill in