summaryrefslogtreecommitdiff
path: root/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
diff options
context:
space:
mode:
authorKarolin Seeger <kseeger@samba.org>2008-02-29 10:44:38 +0100
committerKarolin Seeger <kseeger@samba.org>2008-02-29 10:44:38 +0100
commitc4fbe2846231a6b322c1094c6a1dbf93b7305768 (patch)
tree09eb77a294f4acda131b41fe4c9bec4ed175eb16 /source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
parent1a6415fc77c708b87c8e2ce6e7828f486ffc87ac (diff)
parent695b6662abe64a40061bfa05ede12173fc4b1945 (diff)
downloadsamba-c4fbe2846231a6b322c1094c6a1dbf93b7305768.tar.gz
samba-c4fbe2846231a6b322c1094c6a1dbf93b7305768.tar.bz2
samba-c4fbe2846231a6b322c1094c6a1dbf93b7305768.zip
Merge commit 'origin/v3-2-test' into v3-2-stable
Conflicts: WHATSNEW.txt (This used to be commit a390bcf9403df4cf4d5eef42b35ebccbe253882e)
Diffstat (limited to 'source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c')
-rw-r--r--source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
index 9dc2a18138..73b14d4d87 100644
--- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
+++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <netdb.h>
#include <gtk/gtk.h>
#include <glib/gprintf.h>
@@ -439,7 +440,7 @@ static void callback_do_join(GtkWidget *widget,
state->password,
unjoin_flags);
if (status != 0) {
- err_str = libnetapi_errstr(status);
+ err_str = libnetapi_get_error_string(state->ctx, status);
g_print("callback_do_join: failed to unjoin (%s)\n",
err_str);
@@ -463,7 +464,7 @@ static void callback_do_join(GtkWidget *widget,
state->password,
join_flags);
if (status != 0) {
- err_str = libnetapi_errstr(status);
+ err_str = libnetapi_get_error_string(state->ctx, status);
g_print("callback_do_join: failed to join (%s)\n", err_str);
dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_parent),
@@ -1263,37 +1264,56 @@ static int initialize_join_state(struct join_state *state,
{
char my_hostname[HOST_NAME_MAX];
const char *p = NULL;
+ struct hostent *hp = NULL;
+
if (gethostname(my_hostname, sizeof(my_hostname)) == -1) {
return -1;
}
- state->my_fqdn = strdup(my_hostname);
+ p = strchr(my_hostname, '.');
+ if (p) {
+ my_hostname[strlen(my_hostname)-strlen(p)] = '\0';
+ }
+ state->my_hostname = strdup(my_hostname);
+ if (!state->my_hostname) {
+ return -1;
+ }
+ debug("state->my_hostname: %s\n", state->my_hostname);
+
+ hp = gethostbyname(my_hostname);
+ if (!hp || !hp->h_name || !*hp->h_name) {
+ return -1;
+ }
+
+ state->my_fqdn = strdup(hp->h_name);
if (!state->my_fqdn) {
return -1;
}
+ debug("state->my_fqdn: %s\n", state->my_fqdn);
- p = strchr(my_hostname, '.');
+ p = strchr(state->my_fqdn, '.');
if (p) {
- my_hostname[strlen(my_hostname) - strlen(p)] = '\0';
- state->my_hostname = strdup(my_hostname);
- if (!state->my_hostname) {
- return -1;
- }
p++;
state->my_dnsdomain = strdup(p);
- if (!state->my_dnsdomain) {
- return -1;
- }
+ } else {
+ state->my_dnsdomain = strdup("");
+ }
+ if (!state->my_dnsdomain) {
+ return -1;
}
+ debug("state->my_dnsdomain: %s\n", state->my_dnsdomain);
}
{
const char *buffer = NULL;
uint16_t type = 0;
status = NetGetJoinInformation(NULL, &buffer, &type);
- if (status) {
+ if (status != 0) {
+ printf("NetGetJoinInformation failed with: %s\n",
+ libnetapi_get_error_string(state->ctx, status));
return status;
}
+ debug("NetGetJoinInformation gave: %s and %d\n", buffer, type);
state->name_buffer_initial = strdup(buffer);
if (!state->name_buffer_initial) {
return -1;
@@ -1307,7 +1327,9 @@ static int initialize_join_state(struct join_state *state,
uint8_t *buffer = NULL;
status = NetServerGetInfo(NULL, 1005, &buffer);
- if (status) {
+ if (status != 0) {
+ printf("NetServerGetInfo failed with: %s\n",
+ libnetapi_get_error_string(state->ctx, status));
return status;
}