Changeset 988 for vendor/current/source4/lib/cmdline
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/lib/cmdline
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/lib/cmdline/credentials.c
r414 r988 25 25 static const char *cmdline_get_userpassword(struct cli_credentials *credentials) 26 26 { 27 char *ret;28 27 TALLOC_CTX *mem_ctx = talloc_new(NULL); 29 30 28 const char *prompt_name = cli_credentials_get_unparsed_name(credentials, mem_ctx); 31 29 const char *prompt; 30 static char pwd[256]; /* FIXME: Return a dup pwd and free it. */ 31 int rc; 32 32 33 33 prompt = talloc_asprintf(mem_ctx, "Password for [%s]:", 34 34 prompt_name); 35 35 36 ret = getpass(prompt); 36 memset(pwd, '\0', sizeof(pwd)); 37 rc = samba_getpass(prompt, pwd, sizeof(pwd), false, false); 38 talloc_free(mem_ctx); 39 if (rc < 0) { 40 return NULL; 41 } 37 42 38 talloc_free(mem_ctx); 39 return ret; 43 return pwd; 40 44 } 41 45 -
vendor/current/source4/lib/cmdline/popt_common.c
r740 r988 84 84 85 85 if (reason == POPT_CALLBACK_REASON_PRE) { 86 cmdline_lp_ctx = loadparm_init_global(false);87 88 86 /* Hook for 'almost the first thing to do in a samba program' here */ 89 87 /* setup for panics */ 90 fault_setup( poptGetInvocationName(con));88 fault_setup(); 91 89 92 90 /* and logging */ 93 setup_logging(pname, DEBUG_ STDOUT);91 setup_logging(pname, DEBUG_DEFAULT_STDOUT); 94 92 talloc_set_log_fn(popt_s4_talloc_log_fn); 95 93 talloc_set_abort_fn(smb_panic); 96 94 95 cmdline_lp_ctx = loadparm_init_global(false); 97 96 return; 98 97 } … … 188 187 } 189 188 190 struct poptOption popt_common_connection [] = {189 struct poptOption popt_common_connection4[] = { 191 190 { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_common_callback }, 192 191 { "name-resolve", 'R', POPT_ARG_STRING, NULL, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, … … 201 200 }; 202 201 203 struct poptOption popt_common_samba [] = {202 struct poptOption popt_common_samba4[] = { 204 203 { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_samba_callback }, 205 204 { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, … … 213 212 }; 214 213 215 struct poptOption popt_common_version [] = {214 struct poptOption popt_common_version4[] = { 216 215 { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_version_callback }, 217 216 { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, -
vendor/current/source4/lib/cmdline/popt_common.h
r414 r988 24 24 25 25 /* Common popt structures */ 26 extern struct poptOption popt_common_samba [];27 extern struct poptOption popt_common_connection [];28 extern struct poptOption popt_common_version [];29 extern struct poptOption popt_common_credentials [];26 extern struct poptOption popt_common_samba4[]; 27 extern struct poptOption popt_common_connection4[]; 28 extern struct poptOption popt_common_version4[]; 29 extern struct poptOption popt_common_credentials4[]; 30 30 31 31 #ifndef POPT_TABLEEND … … 33 33 #endif 34 34 35 #define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_samba , 0, "Common samba options:", NULL },36 #define POPT_COMMON_CONNECTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_connection , 0, "Connection options:", NULL },37 #define POPT_COMMON_VERSION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version , 0, "Common sambaoptions:", NULL },38 #define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials , 0, "Authentication options:", NULL },35 #define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_samba4, 0, "Common Samba options:", NULL }, 36 #define POPT_COMMON_CONNECTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_connection4, 0, "Connection options:", NULL }, 37 #define POPT_COMMON_VERSION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version4, 0, "Version options:", NULL }, 38 #define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials4, 0, "Authentication options:", NULL }, 39 39 40 40 extern struct cli_credentials *cmdline_credentials; 41 41 extern struct loadparm_context *cmdline_lp_ctx; 42 42 43 void popt_common_dont_ask(void);44 45 43 #endif /* _POPT_COMMON_H */ -
vendor/current/source4/lib/cmdline/popt_credentials.c
r740 r988 35 35 * --simple-bind-dn 36 36 * --password 37 * --krb5-ccache 37 38 */ 38 39 … … 40 41 static bool machine_account_pending; 41 42 42 enum opt { OPT_SIMPLE_BIND_DN, OPT_PASSWORD, OPT_KERBEROS, OPT_SIGN, OPT_ENCRYPT }; 43 44 /* 45 disable asking for a password 46 */ 47 void popt_common_dont_ask(void) 48 { 49 dont_ask = true; 50 } 43 enum opt { OPT_SIMPLE_BIND_DN, OPT_PASSWORD, OPT_KERBEROS, OPT_SIGN, OPT_ENCRYPT, OPT_KRB5_CCACHE }; 51 44 52 45 static void popt_common_credentials_callback(poptContext con, … … 131 124 break; 132 125 } 126 case OPT_KRB5_CCACHE: 127 { 128 const char *error_string; 129 if (cli_credentials_set_ccache(cmdline_credentials, cmdline_lp_ctx, arg, CRED_SPECIFIED, 130 &error_string) != 0) { 131 fprintf(stderr, "Error reading krb5 credentials cache: '%s' %s", arg, error_string); 132 exit(1); 133 } 134 break; 135 } 133 136 case OPT_SIGN: 134 137 { … … 158 161 159 162 160 struct poptOption popt_common_credentials [] = {163 struct poptOption popt_common_credentials4[] = { 161 164 { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_common_credentials_callback }, 162 165 { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" }, … … 164 167 { "password", 0, POPT_ARG_STRING, NULL, OPT_PASSWORD, "Password" }, 165 168 { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, 166 { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" },169 { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" }, 167 170 { "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" }, 168 171 { "kerberos", 'k', POPT_ARG_STRING, NULL, OPT_KERBEROS, "Use Kerberos, -k [yes|no]" }, 172 { "krb5-ccache", 0, POPT_ARG_STRING, NULL, OPT_KRB5_CCACHE, "Credentials cache location for Kerberos" }, 169 173 { "sign", 'S', POPT_ARG_NONE, NULL, OPT_SIGN, "Sign connection to prevent modification in transit" }, 170 174 { "encrypt", 'e', POPT_ARG_NONE, NULL, OPT_ENCRYPT, "Encrypt connection for privacy" }, -
vendor/current/source4/lib/cmdline/wscript_build
r740 r988 4 4 source='credentials.c', 5 5 autoproto='credentials.h', 6 public_deps='credentials popt', 6 public_deps='samba-credentials popt', 7 deps='samba-util', 7 8 private_library=True) 8 9 … … 10 11 source='popt_common.c', 11 12 public_deps='popt', 12 public_headers='popt_common.h:popt.h',13 13 header_path='samba', 14 14 deps='talloc samba-hostconfig' … … 18 18 source='popt_credentials.c', 19 19 autoproto='popt_credentials.h', 20 public_deps=' credentials CREDENTIALS_SECRETS cmdline-credentials popt',20 public_deps='samba-credentials CREDENTIALS_SECRETS cmdline-credentials popt', 21 21 deps='samba-util' 22 22 )
Note:
See TracChangeset
for help on using the changeset viewer.