s3:netlookup: make use of cli_credentials_init_anon()
[bbaumbach/samba-autobuild/.git] / source3 / utils / net_afs.c
index 6aea513300bd970cd283d65c9e1c1a51d413e352..3668e3cbad87056279ca5ba1983bac3b50ae8a14 100644 (file)
 
 #include "includes.h"
 #include "utils/net.h"
+#include "utils/net_afs.h"
+#include "secrets.h"
+#include "system/filesys.h"
+#include "lib/afs/afs_funcs.h"
+#include "lib/afs/afs_settoken.h"
+
+#ifdef WITH_FAKE_KASERVER
 
 int net_afs_usage(struct net_context *c, int argc, const char **argv)
 {
@@ -35,7 +42,7 @@ int net_afs_key(struct net_context *c, int argc, const char **argv)
        struct afs_keyfile keyfile;
 
        if (argc != 2) {
-               d_printf(_("Usage:")," net afs key <keyfile> cell\n");
+               d_printf("%s net afs key <keyfile> cell\n", _("Usage:"));
                return -1;
        }
 
@@ -45,14 +52,16 @@ int net_afs_key(struct net_context *c, int argc, const char **argv)
        }
 
        if ((fd = open(argv[0], O_RDONLY, 0)) < 0) {
-               d_fprintf(stderr, _("Could not open %s\n", argv[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"));
+               close(fd);
                return -1;
        }
+       close(fd);
 
        if (!secrets_store_afs_keyfile(argv[1], &keyfile)) {
                d_fprintf(stderr, _("Could not write keyfile to secrets.tdb\n"));
@@ -68,7 +77,8 @@ int net_afs_impersonate(struct net_context *c, int argc,
        char *token;
 
        if (argc != 2) {
-               fprintf(stderr, _("Usage:")," net afs impersonate <user> <cell>\n");
+               d_fprintf(stderr, "%s net afs impersonate <user> <cell>\n",
+                         _("Usage:"));
                exit(1);
        }
 
@@ -112,3 +122,4 @@ int net_afs(struct net_context *c, int argc, const char **argv)
        return net_run_function(c, argc, argv, "net afs", func);
 }
 
+#endif /* WITH_FAKE_KASERVER */