s3:lib/afs move afs.c to common lib dir
[samba.git] / source3 / utils / net_afs.c
index 6aea513300bd970cd283d65c9e1c1a51d413e352..44e5193c88467f4d9bd73d011bcd9af279b640c8 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"
 
 int net_afs_usage(struct net_context *c, int argc, const char **argv)
 {
@@ -35,7 +39,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 +49,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 +74,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);
        }