net: Split out "net afs"
authorKai Blin <kai@samba.org>
Wed, 14 May 2008 07:01:53 +0000 (09:01 +0200)
committerKai Blin <kai@samba.org>
Tue, 20 May 2008 12:27:56 +0000 (14:27 +0200)
(This used to be commit 3f10527f79dddff703d31588cad3e9f37176565b)

source3/Makefile.in
source3/configure.in
source3/utils/net.c
source3/utils/net_afs.c [new file with mode: 0644]
source3/utils/net_afs.h [new file with mode: 0644]
source3/utils/net_help.c
source3/utils/net_proto.h

index 51c5ea139355af797c8517caf20422f431632be8..6a1bd8dd10e29b6775af4d0c5732339faa3d11e6 100644 (file)
@@ -888,7 +888,7 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
 NET_OBJ2 = utils/net_registry_util.o utils/net_help_common.o
 
 NET_OBJ = $(NET_OBJ1) \
-         $(NET_OBJ2) \
+         $(NET_OBJ2) @FAKE_KASERVER_OBJ@\
          $(PARAM_WITHOUT_REG_OBJ) $(LIBSMB_OBJ) \
          $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
          $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(LIBADDNS_OBJ0) \
index 9c9d06fa62089c9ddf71ee10839e59701574a9ee..f2691c47cf3c7fb27b2eb4e4dcd116c955d7f046 100644 (file)
@@ -2883,9 +2883,12 @@ if test x"$samba_cv_WITH_AFS" != x"no" ||
     fi
 fi
 
+FAKE_KASERVER_OBJ=""
 if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
+    FAKE_KASERVER_OBJ="utils/net_afs.o"
 fi
+AC_SUBST(FAKE_KASERVER_OBJ)
 
 #################################################
 # check whether to compile AFS/NT ACL mapping module
index ec48ec22c909ccf93694e7179fc6457ad90cc55a..15064302cde456b9defdf32a4977edb02c9e7ad7 100644 (file)
 #include "includes.h"
 #include "utils/net.h"
 
+#ifdef WITH_FAKE_KASERVER
+#include "utils/net_afs.h"
+#endif
+
 /***********************************************************************/
 /* Beginning of internationalization section.  Translatable constants  */
 /* should be kept in this area and referenced in the rest of the code. */
@@ -305,89 +309,6 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
        return 0;
 }
 
-#ifdef WITH_FAKE_KASERVER
-
-int net_help_afs(struct net_context *c, int argc, const char **argv)
-{
-       d_printf("  net afs key filename\n"
-                "\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
-       d_printf("  net afs impersonate <user> <cell>\n"
-                "\tCreates a token for user@cell\n\n");
-       return -1;
-}
-
-static int net_afs_key(struct net_context *c, int argc, const char **argv)
-{
-       int fd;
-       struct afs_keyfile keyfile;
-
-       if (argc != 2) {
-               d_printf("usage: 'net afs key <keyfile> cell'\n");
-               return -1;
-       }
-
-       if (!secrets_init()) {
-               d_fprintf(stderr, "Could not open secrets.tdb\n");
-               return -1;
-       }
-
-       if ((fd = open(argv[0], O_RDONLY, 0)) < 0) {
-               d_fprintf(stderr, "Could not open %s\n", argv[0]);
-               return -1;
-       }
-
-       if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) {
-               d_fprintf(stderr, "Could not read keyfile\n");
-               return -1;
-       }
-
-       if (!secrets_store_afs_keyfile(argv[1], &keyfile)) {
-               d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n");
-               return -1;
-       }
-
-       return 0;
-}
-
-static int net_afs_impersonate(struct net_context *c, int argc,
-                              const char **argv)
-{
-       char *token;
-
-       if (argc != 2) {
-               fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n");
-               exit(1);
-       }
-
-       token = afs_createtoken_str(argv[0], argv[1]);
-
-       if (token == NULL) {
-               fprintf(stderr, "Could not create token\n");
-               exit(1);
-       }
-
-       if (!afs_settoken_str(token)) {
-               fprintf(stderr, "Could not set token into kernel\n");
-               exit(1);
-       }
-
-       printf("Success: %s@%s\n", argv[0], argv[1]);
-       return 0;
-}
-
-static int net_afs(struct net_context *c, int argc, const char **argv)
-{
-       struct functable func[] = {
-               {"key", net_afs_key},
-               {"impersonate", net_afs_impersonate},
-               {"help", net_help_afs},
-               {NULL, NULL}
-       };
-       return net_run_function(c, argc, argv, func, net_help_afs);
-}
-
-#endif /* WITH_FAKE_KASERVER */
-
 static bool search_maxrid(struct pdb_search *search, const char *type,
                          uint32 *max_rid)
 {
diff --git a/source3/utils/net_afs.c b/source3/utils/net_afs.c
new file mode 100644 (file)
index 0000000..f3f2976
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+   Samba Unix/Linux SMB client library
+   net afs commands
+   Copyright (C) 2003  Volker Lendecke  (vl@samba.org)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "utils/net.h"
+
+int net_afs_usage(struct net_context *c, int argc, const char **argv)
+{
+       d_printf("  net afs key filename\n"
+                "\tImports a OpenAFS KeyFile into our secrets.tdb\n\n");
+       d_printf("  net afs impersonate <user> <cell>\n"
+                "\tCreates a token for user@cell\n\n");
+       return -1;
+}
+
+int net_afs_key(struct net_context *c, int argc, const char **argv)
+{
+       int fd;
+       struct afs_keyfile keyfile;
+
+       if (argc != 2) {
+               d_printf("usage: 'net afs key <keyfile> cell'\n");
+               return -1;
+       }
+
+       if (!secrets_init()) {
+               d_fprintf(stderr, "Could not open secrets.tdb\n");
+               return -1;
+       }
+
+       if ((fd = open(argv[0], O_RDONLY, 0)) < 0) {
+               d_fprintf(stderr, "Could not open %s\n", argv[0]);
+               return -1;
+       }
+
+       if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) {
+               d_fprintf(stderr, "Could not read keyfile\n");
+               return -1;
+       }
+
+       if (!secrets_store_afs_keyfile(argv[1], &keyfile)) {
+               d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+int net_afs_impersonate(struct net_context *c, int argc,
+                              const char **argv)
+{
+       char *token;
+
+       if (argc != 2) {
+               fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n");
+               exit(1);
+       }
+
+       token = afs_createtoken_str(argv[0], argv[1]);
+
+       if (token == NULL) {
+               fprintf(stderr, "Could not create token\n");
+               exit(1);
+       }
+
+       if (!afs_settoken_str(token)) {
+               fprintf(stderr, "Could not set token into kernel\n");
+               exit(1);
+       }
+
+       printf("Success: %s@%s\n", argv[0], argv[1]);
+       return 0;
+}
+
+int net_afs(struct net_context *c, int argc, const char **argv)
+{
+       struct functable func[] = {
+               {"key", net_afs_key},
+               {"impersonate", net_afs_impersonate},
+               {"help", net_afs_usage},
+               {NULL, NULL}
+       };
+       return net_run_function(c, argc, argv, func, net_afs_usage);
+}
+
diff --git a/source3/utils/net_afs.h b/source3/utils/net_afs.h
new file mode 100644 (file)
index 0000000..31606dd
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+   Samba Unix/Linux SMB client library
+   net afs commands
+   Copyright (C) 2008  Kai Blin  (kai@samba.org)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _NET_AFS_H_
+#define _NET_AFS_H_
+
+int net_afs_usage(struct net_context *c, int argc, const char **argv);
+int net_afs_key(struct net_context *c, int argc, const char **argv);
+int net_afs_impersonate(struct net_context *c, int argc,
+                              const char **argv);
+int net_afs(struct net_context *c, int argc, const char **argv);
+
+#endif /*_NET_AFS_H_*/
index 3635ba02f3d274ce1c4e646a1260730809d2f2b1..ffd533eedd63785f0748732714e96524a8936413 100644 (file)
@@ -174,7 +174,7 @@ int net_help(struct net_context *c, int argc, const char **argv)
                {"USERSHARE", net_usershare_usage},
                {"USERSIDLIST", net_usersidlist_usage},
 #ifdef WITH_FAKE_KASERVER
-               {"AFS", net_help_afs},
+               {"AFS", net_afs_usage},
 #endif
 
                {"HELP", help_usage},
index d7374b40e6a53a2b2d466e41c6d9804309c7f1ab..3a98c3bc015e7f72c0a9212320f5a5519c26def5 100644 (file)
@@ -49,7 +49,6 @@ int net_run_function(struct net_context *c, int argc, const char **argv,
                                     int argc, const char **argv));
 int net_run_function2(struct net_context *c, int argc, const char **argv,
                      const char *whoami, struct functable2 *table);
-int net_help_afs(struct net_context *c, int argc, const char **argv);
 
 /* The following definitions come from utils/net_ads.c  */