*/
#include "includes.h"
-#include "popt_common.h"
#include "winbind_client.h"
#include "libwbclient/wbclient.h"
-#include "lib/popt/popt.h"
#include "../libcli/auth/libcli_auth.h"
-#if (_SAMBA_BUILD_) >= 4
#include "lib/cmdline/popt_common.h"
-#endif
+#include "lib/afs/afs_settoken.h"
#ifdef DBGC_CLASS
#undef DBGC_CLASS
if (!p) {
/* Maybe it was a UPN? */
- if ((p = strchr(domuser, '@')) != NULL) {
+ p = strchr(domuser, '@');
+ if (p != NULL) {
fstrcpy(domain, "");
fstrcpy(user, domuser);
return true;
fstrcpy(user, p+1);
fstrcpy(domain, domuser);
domain[PTR_DIFF(p, domuser)] = 0;
- strupper_m(domain);
return true;
}
pwd->pw_dir,
pwd->pw_shell);
+ wbcFreeMemory(pwd);
+
return true;
}
pwd->pw_dir,
pwd->pw_shell);
+ wbcFreeMemory(pwd);
+
return true;
}
pwd->pw_dir,
pwd->pw_shell);
+ wbcFreeMemory(pwd);
+
return true;
}
}
for (i = 0; i < num_sids; i++) {
- char *str = NULL;
- wbc_status = wbcSidToString(&sids[i], &str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: "
- "%s\n", wbcErrorString(wbc_status));
- wbcFreeMemory(sids);
- return false;
- }
+ char str[WBC_SID_STRING_BUFLEN];
+ wbcSidToStringBuf(&sids[i], str, sizeof(str));
d_printf("%s\n", str);
- wbcFreeMemory(str);
}
wbcFreeMemory(sids);
wbc_status = wbcStringToSid(user_sid_str, &user_sid);
if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: %s\n",
+ d_fprintf(stderr, "failed to call wbcStringToSid: %s\n",
wbcErrorString(wbc_status));
return false;
}
}
for (i = 0; i < num_sids; i++) {
- char *str = NULL;
- wbc_status = wbcSidToString(&sids[i], &str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: "
- "%s\n", wbcErrorString(wbc_status));
- wbcFreeMemory(sids);
- return false;
- }
+ char str[WBC_SID_STRING_BUFLEN];
+ wbcSidToStringBuf(&sids[i], str, sizeof(str));
d_printf("%s\n", str);
- wbcFreeMemory(str);
}
wbcFreeMemory(sids);
struct wbcDomainSid user_sid;
uint32_t *alias_rids = NULL;
uint32_t num_alias_rids;
- char *domain_sid_str = NULL;
+ char domain_sid_str[WBC_SID_STRING_BUFLEN];
/* Send request */
if ((domain == NULL) || (strequal(domain, ".")) ||
goto done;
}
- wbc_status = wbcSidToString(&dinfo->sid, &domain_sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- goto done;
- }
+ wbcSidToStringBuf(&dinfo->sid, domain_sid_str, sizeof(domain_sid_str));
for (i = 0; i < num_alias_rids; i++) {
d_printf("%s-%d\n", domain_sid_str, alias_rids[i]);
wbcFreeMemory(alias_rids);
done:
- if (domain_sid_str) {
- wbcFreeMemory(domain_sid_str);
- }
- if (dinfo) {
- wbcFreeMemory(dinfo);
- }
+ wbcFreeMemory(dinfo);
return (WBC_ERR_SUCCESS == wbc_status);
}
}
if (print_all) {
- d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",
+ d_printf("%-16s%-65s%-12s%-12s%-5s%-5s\n",
"Domain Name", "DNS Domain", "Trust Type",
"Transitive", "In", "Out");
}
continue;
}
- d_printf("%-24s", domain_list[i].dns_name);
+ d_printf("%-65s", domain_list[i].dns_name);
switch(domain_list[i].trust_type) {
case WBC_DOMINFO_TRUSTTYPE_NONE:
d_printf("\n");
}
+ wbcFreeMemory(domain_list);
+
return true;
}
is_offline ? "offline" : "online" );
}
+ wbcFreeMemory(domain_list);
+
return true;
}
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcDomainInfo *dinfo = NULL;
- char *sid_str = NULL;
+ char sid_str[WBC_SID_STRING_BUFLEN];
if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0')){
domain = get_winbind_domain();
return false;
}
- wbc_status = wbcSidToString(&dinfo->sid, &sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: %s\n",
- wbcErrorString(wbc_status));
- wbcFreeMemory(dinfo);
- return false;
- }
+ wbcSidToStringBuf(&dinfo->sid, sid_str, sizeof(sid_str));
/* Display response */
(dinfo->domain_flags & WBC_DOMINFO_DOMAIN_PRIMARY) ?
"Yes" : "No");
- wbcFreeMemory(sid_str);
wbcFreeMemory(dinfo);
return true;
/* Send request */
- if (winbindd_request_response(WINBINDD_GETDCNAME, &request,
+ if (winbindd_request_response(NULL, WINBINDD_GETDCNAME, &request,
&response) != NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not get dc name for %s\n",domain_name);
return false;
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
if (wbc_status == WBC_ERR_AUTH_ERROR) {
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- error->nt_string, error->nt_status);
+ d_fprintf(stderr, "wbcCheckTrustCredentials(%s): error code was %s (0x%x)\n",
+ domain_name, error->nt_string, error->nt_status);
wbcFreeMemory(error);
}
if (!WBC_ERROR_IS_OK(wbc_status)) {
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
if (wbc_status == WBC_ERR_AUTH_ERROR) {
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- error->nt_string, error->nt_status);
+ d_fprintf(stderr, "wbcChangeTrustCredentials(%s): error code was %s (0x%x)\n",
+ domain_name, error->nt_string, error->nt_status);
wbcFreeMemory(error);
}
if (!WBC_ERROR_IS_OK(wbc_status)) {
/* Check DC connection */
-static bool wbinfo_ping_dc(void)
+static bool wbinfo_ping_dc(const char *domain)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcAuthErrorInfo *error = NULL;
+ char *dcname = NULL;
- wbc_status = wbcPingDc(NULL, &error);
+ const char *domain_name;
- d_printf("checking the NETLOGON dc connection %s\n",
+ if (domain) {
+ domain_name = domain;
+ } else {
+ domain_name = get_winbind_domain();
+ }
+
+ wbc_status = wbcPingDc2(domain_name, &error, &dcname);
+
+ d_printf("checking the NETLOGON for domain[%s] dc connection to \"%s\" %s\n",
+ domain_name ? domain_name : "",
+ dcname ? dcname : "",
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
+ wbcFreeMemory(dcname);
if (wbc_status == WBC_ERR_AUTH_ERROR) {
- d_fprintf(stderr, "error code was %s (0x%x)\n",
- error->nt_string, error->nt_status);
+ d_fprintf(stderr, "wbcPingDc2(%s): error code was %s (0x%x)\n",
+ domain_name, error->nt_string, error->nt_status);
wbcFreeMemory(error);
+ return false;
}
if (!WBC_ERROR_IS_OK(wbc_status)) {
d_fprintf(stderr, "failed to call wbcPingDc: %s\n",
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcDomainSid sid;
- char *sid_str = NULL;
+ char sid_str[WBC_SID_STRING_BUFLEN];
/* Send request */
return false;
}
- wbc_status = wbcSidToString(&sid, &sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: %s\n",
- wbcErrorString(wbc_status));
- return false;
- }
+ wbcSidToStringBuf(&sid, sid_str, sizeof(sid_str));
/* Display response */
d_printf("%s\n", sid_str);
- wbcFreeMemory(sid_str);
-
return true;
}
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcDomainSid sid;
- char *sid_str = NULL;
+ char sid_str[WBC_SID_STRING_BUFLEN];
/* Send request */
return false;
}
- wbc_status = wbcSidToString(&sid, &sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: %s\n",
- wbcErrorString(wbc_status));
- return false;
- }
+ wbcSidToStringBuf(&sid, sid_str, sizeof(sid_str));
/* Display response */
d_printf("%s\n", sid_str);
- wbcFreeMemory(sid_str);
-
return true;
}
return true;
}
+static bool wbinfo_sids_to_unix_ids(const char *arg)
+{
+ char sidstr[WBC_SID_STRING_BUFLEN];
+ struct wbcDomainSid *sids;
+ struct wbcUnixId *unix_ids;
+ int i, num_sids;
+ const char *p;
+ wbcErr wbc_status;
+
+
+ num_sids = 0;
+ sids = NULL;
+ p = arg;
+
+ while (next_token(&p, sidstr, LIST_SEP, sizeof(sidstr))) {
+ sids = talloc_realloc(talloc_tos(), sids, struct wbcDomainSid,
+ num_sids+1);
+ if (sids == NULL) {
+ d_fprintf(stderr, "talloc failed\n");
+ return false;
+ }
+ wbc_status = wbcStringToSid(sidstr, &sids[num_sids]);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "wbcSidToString(%s) failed: %s\n",
+ sidstr, wbcErrorString(wbc_status));
+ TALLOC_FREE(sids);
+ return false;
+ }
+ num_sids += 1;
+ }
+
+ unix_ids = talloc_array(talloc_tos(), struct wbcUnixId, num_sids);
+ if (unix_ids == NULL) {
+ TALLOC_FREE(sids);
+ return false;
+ }
+
+ wbc_status = wbcSidsToUnixIds(sids, num_sids, unix_ids);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "wbcSidsToUnixIds failed: %s\n",
+ wbcErrorString(wbc_status));
+ TALLOC_FREE(sids);
+ return false;
+ }
+
+ for (i=0; i<num_sids; i++) {
+
+ wbcSidToStringBuf(&sids[i], sidstr, sizeof(sidstr));
+
+ switch(unix_ids[i].type) {
+ case WBC_ID_TYPE_UID:
+ d_printf("%s -> uid %d\n", sidstr, unix_ids[i].id.uid);
+ break;
+ case WBC_ID_TYPE_GID:
+ d_printf("%s -> gid %d\n", sidstr, unix_ids[i].id.gid);
+ break;
+ case WBC_ID_TYPE_BOTH:
+ d_printf("%s -> uid/gid %d\n", sidstr, unix_ids[i].id.uid);
+ break;
+ default:
+ d_printf("%s -> unmapped\n", sidstr);
+ break;
+ }
+ }
+
+ TALLOC_FREE(sids);
+ TALLOC_FREE(unix_ids);
+
+ return true;
+}
+
static bool wbinfo_allocate_uid(void)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
return true;
}
+static bool wbinfo_set_uid_mapping(uid_t uid, const char *sid_str)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcDomainSid sid;
+
+ /* Send request */
+
+ wbc_status = wbcStringToSid(sid_str, &sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "failed to call wbcStringToSid: %s\n",
+ wbcErrorString(wbc_status));
+ return false;
+ }
+
+ wbc_status = wbcSetUidMapping(uid, &sid);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "failed to call wbcSetUidMapping: %s\n",
+ wbcErrorString(wbc_status));
+ return false;
+ }
+
+ /* Display response */
+
+ d_printf("uid %u now mapped to sid %s\n",
+ (unsigned int)uid, sid_str);
+
+ return true;
+}
+
static bool wbinfo_set_gid_mapping(gid_t gid, const char *sid_str)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
/* Display response */
- d_printf("%s%c%s %d\n",
- domain, winbind_separator(), name, type);
+ if (type == WBC_SID_NAME_DOMAIN) {
+ d_printf("%s %d\n", domain, type);
+ } else {
+ d_printf("%s%c%s %d\n",
+ domain, winbind_separator(), name, type);
+ }
+
+ wbcFreeMemory(domain);
+ wbcFreeMemory(name);
return true;
}
d_printf("%s%c%s %d\n",
domain, winbind_separator(), name, type);
+ wbcFreeMemory(domain);
+ wbcFreeMemory(name);
+
return true;
}
}
wbc_status = wbcLookupRids(&dinfo->sid, num_rids, rids,
- (const char **)&domain_name, &names, &types);
+ &p, &names, &types);
if (!WBC_ERROR_IS_OK(wbc_status)) {
d_printf("winbind_lookup_rids failed: %s\n",
wbcErrorString(wbc_status));
goto done;
}
+ domain_name = discard_const_p(char, p);
d_printf("Domain: %s\n", domain_name);
for (i=0; i<num_rids; i++) {
ret = true;
done:
- if (dinfo) {
- wbcFreeMemory(dinfo);
- }
- if (domain_name) {
- wbcFreeMemory(domain_name);
+ wbcFreeMemory(dinfo);
+ wbcFreeMemory(domain_name);
+ wbcFreeMemory(names);
+ wbcFreeMemory(types);
+ TALLOC_FREE(mem_ctx);
+ return ret;
+}
+
+static bool wbinfo_lookup_sids(const char *arg)
+{
+ char sidstr[WBC_SID_STRING_BUFLEN];
+ struct wbcDomainSid *sids;
+ struct wbcDomainInfo *domains;
+ struct wbcTranslatedName *names;
+ int num_domains;
+ int i, num_sids;
+ const char *p;
+ wbcErr wbc_status;
+
+
+ num_sids = 0;
+ sids = NULL;
+ p = arg;
+
+ while (next_token(&p, sidstr, LIST_SEP, sizeof(sidstr))) {
+ sids = talloc_realloc(talloc_tos(), sids, struct wbcDomainSid,
+ num_sids+1);
+ if (sids == NULL) {
+ d_fprintf(stderr, "talloc failed\n");
+ return false;
+ }
+ wbc_status = wbcStringToSid(sidstr, &sids[num_sids]);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "wbcSidToString(%s) failed: %s\n",
+ sidstr, wbcErrorString(wbc_status));
+ TALLOC_FREE(sids);
+ return false;
+ }
+ num_sids += 1;
}
- if (names) {
- wbcFreeMemory(names);
+
+ wbc_status = wbcLookupSids(sids, num_sids, &domains, &num_domains,
+ &names);
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ d_fprintf(stderr, "wbcLookupSids failed: %s\n",
+ wbcErrorString(wbc_status));
+ TALLOC_FREE(sids);
+ return false;
}
- if (types) {
- wbcFreeMemory(types);
+
+ for (i=0; i<num_sids; i++) {
+ const char *domain = NULL;
+
+ wbcSidToStringBuf(&sids[i], sidstr, sizeof(sidstr));
+
+ if (names[i].domain_index >= num_domains) {
+ domain = "<none>";
+ } else if (names[i].domain_index < 0) {
+ domain = "<none>";
+ } else {
+ domain = domains[names[i].domain_index].short_name;
+ }
+
+ if (names[i].type == WBC_SID_NAME_DOMAIN) {
+ d_printf("%s -> %s %d\n", sidstr,
+ domain,
+ names[i].type);
+ } else {
+ d_printf("%s -> %s%c%s %d\n", sidstr,
+ domain,
+ winbind_separator(),
+ names[i].name, names[i].type);
+ }
}
- TALLOC_FREE(mem_ctx);
- return ret;
+ wbcFreeMemory(names);
+ wbcFreeMemory(domains);
+ return true;
}
/* Convert string to sid */
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcDomainSid sid;
- char *sid_str;
+ char sid_str[WBC_SID_STRING_BUFLEN];
enum wbcSidType type;
fstring domain_name;
fstring account_name;
return false;
}
- wbc_status = wbcSidToString(&sid, &sid_str);
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- d_fprintf(stderr, "failed to call wbcSidToString: %s\n",
- wbcErrorString(wbc_status));
- return false;
- }
+ wbcSidToStringBuf(&sid, sid_str, sizeof(sid_str));
/* Display response */
d_printf("%s %s (%d)\n", sid_str, wbcSidTypeString(type), type);
- wbcFreeMemory(sid_str);
-
return true;
}
const char *username)
{
char *prompt;
- const char *ret = NULL;
+ char buf[1024] = {0};
+ int rc;
prompt = talloc_asprintf(mem_ctx, "Enter %s's ", username);
if (!prompt) {
return NULL;
}
- ret = getpass(prompt);
+ rc = samba_getpass(prompt, buf, sizeof(buf), false, false);
TALLOC_FREE(prompt);
+ if (rc < 0) {
+ return NULL;
+ }
- return talloc_strdup(mem_ctx, ret);
+ return talloc_strdup(mem_ctx, buf);
}
/* Authenticate a user with a plaintext password */
if (error) {
d_fprintf(stderr,
- "error code was %s (0x%x)\nerror message was: %s\n",
- error->nt_string,
+ "wbcLogonUser(%s): error code was %s (0x%x)\n"
+ "error message was: %s\n",
+ params.username, error->nt_string,
error->nt_status,
error->display_string);
}
if (wbc_status == WBC_ERR_AUTH_ERROR) {
d_fprintf(stderr,
- "error code was %s (0x%x)\nerror message was: %s\n",
+ "wbcAuthenticateUserEx(%s%c%s): error code was %s (0x%x)\n"
+ "error message was: %s\n",
+ name_domain,
+ winbind_separator(),
+ name_user,
err->nt_string,
err->nt_status,
err->display_string);
/* Authenticate a user with a plaintext password */
-static bool wbinfo_pam_logon(char *username)
+static bool wbinfo_pam_logon(char *username, bool verbose)
{
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
struct wbcLogonUserParams params;
- struct wbcAuthErrorInfo *error;
+ struct wbcLogonUserInfo *info = NULL;
+ struct wbcAuthErrorInfo *error = NULL;
char *s = NULL;
char *p = NULL;
TALLOC_CTX *frame = talloc_tos();
return false;
}
- wbc_status = wbcLogonUser(¶ms, NULL, &error, NULL);
+ wbc_status = wbcLogonUser(¶ms, &info, &error, NULL);
+
+ if (verbose && (info != NULL)) {
+ struct wbcAuthUserInfo *i = info->info;
+ uint32_t j;
+
+ if (i->account_name != NULL) {
+ d_printf("account_name: %s\n", i->account_name);
+ }
+ if (i->user_principal != NULL) {
+ d_printf("user_principal: %s\n", i->user_principal);
+ }
+ if (i->full_name != NULL) {
+ d_printf("full_name: %s\n", i->full_name);
+ }
+ if (i->domain_name != NULL) {
+ d_printf("domain_name: %s\n", i->domain_name);
+ }
+ if (i->dns_domain_name != NULL) {
+ d_printf("dns_domain_name: %s\n", i->dns_domain_name);
+ }
+ if (i->logon_server != NULL) {
+ d_printf("logon_server: %s\n", i->logon_server);
+ }
+ if (i->logon_script != NULL) {
+ d_printf("logon_script: %s\n", i->logon_script);
+ }
+ if (i->profile_path != NULL) {
+ d_printf("profile_path: %s\n", i->profile_path);
+ }
+ if (i->home_directory != NULL) {
+ d_printf("home_directory: %s\n", i->home_directory);
+ }
+ if (i->home_drive != NULL) {
+ d_printf("home_drive: %s\n", i->home_drive);
+ }
+
+ d_printf("sids:");
+
+ for (j=0; j<i->num_sids; j++) {
+ char buf[WBC_SID_STRING_BUFLEN];
+ wbcSidToStringBuf(&i->sids[j].sid, buf, sizeof(buf));
+ d_printf(" %s", buf);
+ }
+ d_printf("\n");
+
+ wbcFreeMemory(info);
+ info = NULL;
+ }
wbcFreeMemory(params.blobs);
d_printf("plaintext password authentication %s\n",
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
- if (!WBC_ERROR_IS_OK(wbc_status)) {
+ if (!WBC_ERROR_IS_OK(wbc_status) && (error != NULL)) {
d_fprintf(stderr,
- "error code was %s (0x%x)\nerror message was: %s\n",
+ "wbcLogonUser(%s): error code was %s (0x%x)\n"
+ "error message was: %s\n",
+ params.username,
error->nt_string,
(int)error->nt_status,
error->display_string);
wbcFreeMemory(error);
- return false;
}
- return true;
+ return WBC_ERROR_IS_OK(wbc_status);
}
/* Save creds with winbind */
*p = '%';
} else {
fstrcpy(request.data.auth.user, username);
- fstrcpy(request.data.auth.pass, getpass("Password: "));
+ (void) samba_getpass("Password: ",
+ request.data.auth.pass,
+ sizeof(request.data.auth.pass),
+ false, false);
}
request.flags |= WBFLAG_PAM_AFS_TOKEN;
- result = winbindd_request_response(WINBINDD_PAM_AUTH, &request,
+ result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH, &request,
&response);
/* Display response */
/* Send request to winbind daemon */
- /* '.' is the special sign for our own domain */
- if (domain && strcmp(domain, ".") == 0) {
+ if (domain == NULL) {
domain = get_winbind_domain();
+ } else {
+ /* '.' is the special sign for our own domain */
+ if ((domain[0] == '\0') || strcmp(domain, ".") == 0) {
+ domain = get_winbind_domain();
+ /* '*' is the special sign for all domains */
+ } else if (strcmp(domain, "*") == 0) {
+ domain = NULL;
+ }
}
wbc_status = wbcListUsers(domain, &num_users, &users);
/* Send request to winbind daemon */
- /* '.' is the special sign for our own domain */
- if (domain && strcmp(domain, ".") == 0) {
+ if (domain == NULL) {
domain = get_winbind_domain();
+ } else {
+ /* '.' is the special sign for our own domain */
+ if ((domain[0] == '\0') || strcmp(domain, ".") == 0) {
+ domain = get_winbind_domain();
+ /* '*' is the special sign for all domains */
+ } else if (strcmp(domain, "*") == 0) {
+ domain = NULL;
+ }
}
wbc_status = wbcListGroups(domain, &num_groups, &groups);
OPT_USERDOMGROUPS,
OPT_SIDALIASES,
OPT_USERSIDS,
+ OPT_LOOKUP_SIDS,
OPT_ALLOCATE_UID,
OPT_ALLOCATE_GID,
+ OPT_SET_UID_MAPPING,
OPT_SET_GID_MAPPING,
OPT_REMOVE_UID_MAPPING,
OPT_REMOVE_GID_MAPPING,
+ OPT_SIDS_TO_XIDS,
OPT_SEPARATOR,
OPT_LIST_ALL_DOMAINS,
OPT_LIST_OWN_DOMAIN,
OPT_LOGOFF,
OPT_LOGOFF_USER,
OPT_LOGOFF_UID,
- OPT_LANMAN
+ OPT_LANMAN,
+ OPT_KRB5CCNAME
};
-int main(int argc, char **argv, char **envp)
+int main(int argc, const char **argv, char **envp)
{
int opt;
TALLOC_CTX *frame = talloc_stackframe();
bool use_lanman = false;
char *logoff_user = getenv("USER");
int logoff_uid = geteuid();
+ const char *opt_krb5ccname = "FILE";
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "sid-to-fullname", 0, POPT_ARG_STRING, &string_arg,
OPT_SID_TO_FULLNAME, "Converts sid to fullname", "SID" },
{ "lookup-rids", 'R', POPT_ARG_STRING, &string_arg, 'R', "Converts RIDs to names", "RIDs" },
+ { "lookup-sids", 0, POPT_ARG_STRING, &string_arg,
+ OPT_LOOKUP_SIDS, "Converts SIDs to types and names",
+ "Sid-List"},
{ "uid-to-sid", 'U', POPT_ARG_INT, &int_arg, 'U', "Converts uid to sid" , "UID" },
{ "gid-to-sid", 'G', POPT_ARG_INT, &int_arg, 'G', "Converts gid to sid", "GID" },
{ "sid-to-uid", 'S', POPT_ARG_STRING, &string_arg, 'S', "Converts sid to uid", "SID" },
"Get a new UID out of idmap" },
{ "allocate-gid", 0, POPT_ARG_NONE, 0, OPT_ALLOCATE_GID,
"Get a new GID out of idmap" },
+ { "set-uid-mapping", 0, POPT_ARG_STRING, &string_arg, OPT_SET_UID_MAPPING, "Create or modify uid to sid mapping in idmap", "UID,SID" },
{ "set-gid-mapping", 0, POPT_ARG_STRING, &string_arg, OPT_SET_GID_MAPPING, "Create or modify gid to sid mapping in idmap", "GID,SID" },
{ "remove-uid-mapping", 0, POPT_ARG_STRING, &string_arg, OPT_REMOVE_UID_MAPPING, "Remove uid to sid mapping in idmap", "UID,SID" },
{ "remove-gid-mapping", 0, POPT_ARG_STRING, &string_arg, OPT_REMOVE_GID_MAPPING, "Remove gid to sid mapping in idmap", "GID,SID" },
+ { "sids-to-unix-ids", 0, POPT_ARG_STRING, &string_arg,
+ OPT_SIDS_TO_XIDS, "Translate SIDs to Unix IDs", "Sid-List" },
{ "check-secret", 't', POPT_ARG_NONE, 0, 't', "Check shared secret" },
{ "change-secret", 'c', POPT_ARG_NONE, 0, 'c', "Change shared secret" },
{ "ping-dc", 'P', POPT_ARG_NONE, 0, 'P',
{ "krb5auth", 'K', POPT_ARG_STRING, &string_arg, 'K', "authenticate user using Kerberos", "user%password" },
/* destroys wbinfo --help output */
/* "user%password,DOM\\user%password,user@EXAMPLE.COM,EXAMPLE.COM\\user%password" }, */
+ { "krb5ccname", 0, POPT_ARG_STRING, &opt_krb5ccname, OPT_KRB5CCNAME, "authenticate user using Kerberos and specific credential cache type", "krb5ccname" },
#endif
{ "separator", 0, POPT_ARG_NONE, 0, OPT_SEPARATOR, "Get the active winbind separator", NULL },
{ "verbose", 0, POPT_ARG_NONE, 0, OPT_VERBOSE, "Print additional information per command", NULL },
};
/* Samba client initialisation */
- load_case_tables();
+ smb_init_locale();
/* Parse options */
- pc = poptGetContext("wbinfo", argc, (const char **)argv,
+ pc = poptGetContext("wbinfo", argc, argv,
long_options, 0);
/* Parse command line options */
goto done;
}
break;
+ case OPT_LOOKUP_SIDS:
+ if (!wbinfo_lookup_sids(string_arg)) {
+ d_fprintf(stderr, "Could not lookup SIDs %s\n",
+ string_arg);
+ goto done;
+ }
+ break;
case 'n':
if (!wbinfo_lookupname(string_arg)) {
d_fprintf(stderr, "Could not lookup name %s\n",
goto done;
}
break;
+ case OPT_SET_UID_MAPPING:
+ if (!parse_mapping_arg(string_arg, &int_subarg,
+ &string_subarg) ||
+ !wbinfo_set_uid_mapping(int_subarg, string_subarg))
+ {
+ d_fprintf(stderr, "Could not create or modify "
+ "uid to sid mapping\n");
+ goto done;
+ }
+ break;
case OPT_SET_GID_MAPPING:
if (!parse_mapping_arg(string_arg, &int_subarg,
&string_subarg) ||
goto done;
}
break;
+ case OPT_SIDS_TO_XIDS:
+ if (!wbinfo_sids_to_unix_ids(string_arg)) {
+ d_fprintf(stderr, "wbinfo_sids_to_unix_ids "
+ "failed\n");
+ goto done;
+ }
+ break;
case 't':
if (!wbinfo_check_secret(opt_domain_name)) {
d_fprintf(stderr, "Could not check secret\n");
}
break;
case 'P':
- if (!wbinfo_ping_dc()) {
- d_fprintf(stderr, "Could not ping our DC\n");
+ if (!wbinfo_ping_dc(opt_domain_name)) {
goto done;
}
break;
break;
}
case OPT_PAM_LOGON:
- if (!wbinfo_pam_logon(string_arg)) {
+ if (!wbinfo_pam_logon(string_arg, verbose)) {
d_fprintf(stderr, "pam_logon failed for %s\n",
string_arg);
goto done;
WBFLAG_PAM_INFO3_TEXT |
WBFLAG_PAM_CONTACT_TRUSTDOM;
- if (!wbinfo_auth_krb5(string_arg, "FILE",
+ if (!wbinfo_auth_krb5(string_arg, opt_krb5ccname,
flags)) {
d_fprintf(stderr,
"Could not authenticate user "
"[%s] with Kerberos "
"(ccache: %s)\n", string_arg,
- "FILE");
+ opt_krb5ccname);
goto done;
}
break;
case OPT_LANMAN:
case OPT_LOGOFF_USER:
case OPT_LOGOFF_UID:
+ case OPT_KRB5CCNAME:
break;
default:
d_fprintf(stderr, "Invalid option\n");