]> git.samba.org - garming/samba-autobuild/.git/commitdiff
s3:lib/afs move afs.c to common lib dir
authorChristian Ambach <ambi@samba.org>
Mon, 14 Apr 2014 20:11:12 +0000 (22:11 +0200)
committerChristian Ambach <ambi@samba.org>
Wed, 4 Jun 2014 18:09:38 +0000 (20:09 +0200)
some of the code in afs.c is needed by wbinfo that lives in the toplevel
nsswitch directory, so move the afs.c file to a new top-level lib/afs
directory. Use the name afs_funcs to avoid collisions with the afs.h
header from OpenAFS

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/afs/afs_funcs.c [moved from source3/lib/afs.c with 96% similarity]
lib/afs/afs_funcs.h [new file with mode: 0644]
lib/afs/wscript_build [new file with mode: 0644]
source3/include/proto.h
source3/smbd/service.c
source3/utils/net_afs.c
source3/winbindd/winbindd_pam.c
source3/wscript_build
wscript_build

similarity index 96%
rename from source3/lib/afs.c
rename to lib/afs/afs_funcs.c
index 2d77526dec8d526e91a12bd122a85a116df9e968..316bb1b5ec1030512e8a0b86df533eb452d47779 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include "includes.h"
+#include "lib/afs/afs_funcs.h"
 
 #ifdef WITH_FAKE_KASERVER
 
@@ -30,7 +31,6 @@
 
 #include <afs/param.h>
 #include <afs/stds.h>
-#include <afs/afs.h>
 #include <afs/auth.h>
 #include <afs/venus.h>
 #include <asm/unistd.h>
@@ -92,7 +92,7 @@ static bool afs_createtoken(const char *username, const char *cell,
        struct afs_key key;
        des_key_schedule key_schedule;
 
-       if (!secrets_init()) 
+       if (!secrets_init())
                return false;
 
        if (!secrets_fetch_afs_key(cell, &key)) {
@@ -103,8 +103,8 @@ static bool afs_createtoken(const char *username, const char *cell,
        ct->AuthHandle = key.kvno;
 
        /* Build the ticket. This is going to be encrypted, so in our
-           way we fill in ct while we still have the unencrypted
-           form. */
+          way we fill in ct while we still have the unencrypted
+          form. */
 
        p = clear_ticket;
 
@@ -121,7 +121,7 @@ static bool afs_createtoken(const char *username, const char *cell,
        p += strlen(p)+1;
 
        /* Alice's network layer address. At least Openafs-1.2.10
-           ignores this, so we fill in a dummy value here. */
+          ignores this, so we fill in a dummy value here. */
        SIVAL(p, 0, 0);
        p += 4;
 
@@ -129,7 +129,7 @@ static bool afs_createtoken(const char *username, const char *cell,
        generate_random_buffer((uint8_t *)p, 8);
 
        /* Our client code needs the the key in the clear, it does not
-           know the server-key ... */
+          know the server-key ... */
        memcpy(ct->HandShakeKey, p, 8);
 
        p += 8;
@@ -160,7 +160,7 @@ static bool afs_createtoken(const char *username, const char *cell,
        p += 4;
 
        /* And here comes Bob's name and instance, in this case the
-           AFS server. */
+          AFS server. */
        strncpy(p, "afs", sizeof(clear_ticket)-PTR_DIFF(p,clear_ticket)-1);
        p += strlen(p)+1;
        strncpy(p, "", sizeof(clear_ticket)-PTR_DIFF(p,clear_ticket)-1);
diff --git a/lib/afs/afs_funcs.h b/lib/afs/afs_funcs.h
new file mode 100644 (file)
index 0000000..95e916b
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  Generate AFS tickets
+ *  Copyright (C) Volker Lendecke 2003
+ *
+ *  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 LIB_AFS_AFS_FUNCS_H
+#define LIB_AFS_AFS_FUNCS_H 1
+
+char *afs_createtoken_str(const char *username, const char *cell);
+
+/*
+  This routine takes a radical approach completely bypassing the
+  Kerberos idea of security and using AFS simply as an intelligent
+  file backend. Samba has persuaded itself somehow that the user is
+  actually correctly identified and then we create a ticket that the
+  AFS server hopefully accepts using its KeyFile that the admin has
+  kindly stored to our secrets.tdb.
+
+  Thanks to the book "Network Security -- PRIVATE Communication in a
+  PUBLIC World" by Charlie Kaufman, Radia Perlman and Mike Speciner
+  Kerberos 4 tickets are not really hard to construct.
+
+  For the comments "Alice" is the User to be auth'ed, and "Bob" is the
+  AFS server.  */
+
+bool afs_login(connection_struct *conn);
+
+#endif
diff --git a/lib/afs/wscript_build b/lib/afs/wscript_build
new file mode 100644 (file)
index 0000000..45d8be5
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+bld.SAMBA3_SUBSYSTEM('LIBAFS',
+                    source='afs_funcs.c',
+                    deps='samba-util LIBAFS_SETTOKEN')
+
index d401dfbef3e43883c314c9f593576ecdd3677cd6..14af2ad6030ec3a82b0f21f32119e05bb41a3c47 100644 (file)
@@ -35,12 +35,6 @@ bool allow_access(const char **deny_list,
 
 /* The following definitions come from lib/adt_tree.c  */
 
-
-/* The following definitions come from lib/afs.c  */
-
-char *afs_createtoken_str(const char *username, const char *cell);
-bool afs_login(connection_struct *conn);
-
 /* The following definitions come from lib/afs_settoken.c  */
 
 int afs_syscall(int subcall, const char *path, int cmd, char *cmarg, int follow);
index a9ad8477b0f617accb13ea929056ab040f05439a..d3eabf8e3600daa87af8155188bc273c813b748b 100644 (file)
@@ -30,6 +30,7 @@
 #include "auth.h"
 #include "lib/param/loadparm.h"
 #include "messages.h"
+#include "lib/afs/afs_funcs.h"
 
 static bool canonicalize_connect_path(connection_struct *conn)
 {
index 3c7f28242ce73060bd36b4f97c72357c98706ebc..44e5193c88467f4d9bd73d011bcd9af279b640c8 100644 (file)
@@ -22,6 +22,7 @@
 #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)
 {
index 415dc79974c90f7818ca7a026d30414ae824da49..65f27dfcadb6d66b27878577181078798e13108c 100644 (file)
@@ -41,6 +41,7 @@
 #include "auth/kerberos/pac_utils.h"
 #include "auth/gensec/gensec.h"
 #include "librpc/crypto/gse_krb5.h"
+#include "lib/afs/afs_funcs.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
index d319e5e7ac3c678e15c506d7f20ce0f05c1ae459..1f1b75049aadb1e0b0c8d850b8c5576cf30d1893 100755 (executable)
@@ -472,10 +472,6 @@ bld.SAMBA3_SUBSYSTEM('LIBAFS_SETTOKEN',
                     source='lib/afs_settoken.c',
                     deps='samba-util')
 
-bld.SAMBA3_SUBSYSTEM('LIBAFS',
-                    source='lib/afs.c',
-                    deps='samba-util LIBAFS_SETTOKEN')
-
 bld.SAMBA3_LIBRARY('smbconf',
                    source='''lib/smbconf/smbconf_init.c
                    lib/smbconf/smbconf_reg.c''',
index 9228d154107108d8d2c8dcd3bea783e581ca90da..59ba354d48c981d3dc0a2fac8b8fb95dc6ccf097 100644 (file)
@@ -74,6 +74,7 @@ bld.RECURSE('lib/uid_wrapper')
 bld.RECURSE('lib/popt')
 bld.RECURSE('lib/iniparser/src')
 bld.RECURSE('source4/lib/stream')
+bld.RECURSE('lib/afs')
 bld.RECURSE('lib/util')
 bld.RECURSE('lib/tdb_wrap')
 bld.RECURSE('lib/tdr')