dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / krb5 / kadmin / kclient / ksmb.c
blob0e39247e20a9991864502e76fd81505e632ada62
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <strings.h>
32 #include <locale.h>
33 #include <netdb.h>
34 #include <limits.h>
35 #include <smbsrv/libsmbns.h>
37 #define QUOTE(x) #x
38 #define VAL2STR(x) QUOTE(x)
40 char *whoami = NULL;
42 static void usage();
44 static
45 void
46 usage()
48 fprintf(stderr,
49 gettext("Usage: %s [ -d fqdn ] [ -s server ]\n"), whoami);
50 fprintf(stderr,
51 gettext("\t-d\tThe fully qualified domain of the client\n"));
52 fprintf(stderr, gettext("\t-s\tThe domain controller to join\n"));
53 fprintf(stderr,
54 gettext("\tstdin is used to read in the password or \n"));
55 fprintf(stderr, gettext("\tthe password is prompted for.\n"));
57 exit(1);
60 int
61 main(int argc, char **argv)
63 char c, fqdn[MAXHOSTNAMELEN], server[MAXHOSTNAMELEN];
64 char *newpw;
65 int ret = 0;
67 (void) setlocale(LC_ALL, "");
69 #if !defined(TEXT_DOMAIN)
70 #define TEXT_DOMAIN "SYS_TEST"
71 #endif /* TEXT_DOMAIN */
73 (void) textdomain(TEXT_DOMAIN);
75 whoami = argv[0];
77 while ((c = getopt(argc, argv, "d:s:")) != -1) {
78 switch (c) {
79 case 'd':
80 (void) strncpy(fqdn, optarg, sizeof (fqdn));
81 break;
82 case 's':
83 (void) strncpy(server, optarg, sizeof (server));
84 break;
85 default:
86 usage();
87 break;
91 if (argc != optind)
92 usage();
94 if (!isatty(fileno(stdin))) {
95 char buf[PASS_MAX + 1];
97 if (scanf("%" VAL2STR(PASS_MAX) "s", &buf) != 1) {
98 fprintf(stderr,
99 gettext("Couldn't read new password\n"));
100 exit(1);
103 newpw = strdup(buf);
104 if (newpw == NULL) {
105 fprintf(stderr, gettext("Couldn't allocate memory\n"));
106 exit(1);
108 } else {
109 newpw = getpassphrase(gettext("Enter new password: "));
110 if (newpw == NULL) {
111 fprintf(stderr,
112 gettext("Couldn't read new password\n"));
113 exit(1);
116 newpw = strdup(newpw);
117 if (newpw == NULL) {
118 fprintf(stderr, gettext("Couldn't allocate memory\n"));
119 exit(1);
124 * Set the SMF properties for smb for later use.
126 ret = smb_setdomainprops(fqdn, server, newpw);
128 free(newpw);
130 return (ret);