From 558850c495880a916fbc4285993e3adda590453f Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Mon, 14 Apr 2014 22:35:21 +0200 Subject: [PATCH] s3:lib/afs move afs_settoken.c to common lib dir Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett --- lib/afs/afs_funcs.c | 1 + {source3/lib => lib/afs}/afs_settoken.c | 24 +++++++++++++----------- lib/afs/afs_settoken.h | 21 +++++++++++++++++++++ lib/afs/wscript_build | 4 ++++ nsswitch/wbinfo.c | 1 + source3/include/proto.h | 5 ----- source3/modules/vfs_afsacl.c | 1 + source3/utils/net_afs.c | 1 + source3/wscript_build | 4 ---- 9 files changed, 42 insertions(+), 20 deletions(-) rename {source3/lib => lib/afs}/afs_settoken.c (97%) create mode 100644 lib/afs/afs_settoken.h diff --git a/lib/afs/afs_funcs.c b/lib/afs/afs_funcs.c index 316bb1b5ec1..8a3c90a47e5 100644 --- a/lib/afs/afs_funcs.c +++ b/lib/afs/afs_funcs.c @@ -28,6 +28,7 @@ #include "passdb.h" #include "auth.h" #include "../librpc/gen_ndr/ndr_netlogon.h" +#include "lib/afs/afs_settoken.h" #include #include diff --git a/source3/lib/afs_settoken.c b/lib/afs/afs_settoken.c similarity index 97% rename from source3/lib/afs_settoken.c rename to lib/afs/afs_settoken.c index 7aff55fd762..d0ffa49567f 100644 --- a/source3/lib/afs_settoken.c +++ b/lib/afs/afs_settoken.c @@ -1,4 +1,4 @@ -/* +/* * Unix SMB/CIFS implementation. * Generate AFS tickets * Copyright (C) Volker Lendecke 2004 @@ -7,17 +7,18 @@ * 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 . */ #include "includes.h" +#include "lib/afs/afs_settoken.h" #ifdef WITH_FAKE_KASERVER @@ -27,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -92,7 +93,7 @@ static bool afs_decode_token(const char *string, char **cell, DEBUG(10, ("sscanf AuthHandle failed\n")); return false; } - + if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) { DEBUG(10, ("strtok_r failed\n")); return false; @@ -120,7 +121,7 @@ static bool afs_decode_token(const char *string, char **cell, DEBUG(10, ("sscanf ViceId failed\n")); return false; } - + if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) { DEBUG(10, ("strtok_r failed\n")); return false; @@ -130,7 +131,7 @@ static bool afs_decode_token(const char *string, char **cell, DEBUG(10, ("sscanf BeginTimestamp failed\n")); return false; } - + if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) { DEBUG(10, ("strtok_r failed\n")); return false; @@ -140,7 +141,7 @@ static bool afs_decode_token(const char *string, char **cell, DEBUG(10, ("sscanf EndTimestamp failed\n")); return false; } - + if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) { DEBUG(10, ("strtok_r failed\n")); return false; @@ -166,7 +167,7 @@ static bool afs_decode_token(const char *string, char **cell, This is currently highly Linux and OpenAFS-specific. The correct API call for this would be ktc_SetToken. But to do that we would have to import a REALLY big bunch of libraries which I would currently like - to avoid. + to avoid. */ static bool afs_settoken(const char *cell, @@ -235,8 +236,9 @@ bool afs_settoken_str(const char *token_string) if (!afs_decode_token(token_string, &cell, &ticket, &ct)) return false; - if (geteuid() != sec_initial_uid()) - ct.ViceId = getuid(); + if (geteuid() != 0) { + ct.ViceId = geteuid(); + } result = afs_settoken(cell, &ct, ticket); diff --git a/lib/afs/afs_settoken.h b/lib/afs/afs_settoken.h new file mode 100644 index 00000000000..d6cc4621a76 --- /dev/null +++ b/lib/afs/afs_settoken.h @@ -0,0 +1,21 @@ +/* + * Unix SMB/CIFS implementation. + * Generate AFS tickets + * Copyright (C) Volker Lendecke 2004 + * + * 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 . + */ + +int afs_syscall(int subcall, const char *path, int cmd, char *cmarg, int follow); +bool afs_settoken_str(const char *token_string); diff --git a/lib/afs/wscript_build b/lib/afs/wscript_build index 45d8be5795f..7337491fe7c 100644 --- a/lib/afs/wscript_build +++ b/lib/afs/wscript_build @@ -4,3 +4,7 @@ bld.SAMBA3_SUBSYSTEM('LIBAFS', source='afs_funcs.c', deps='samba-util LIBAFS_SETTOKEN') +bld.SAMBA3_SUBSYSTEM('LIBAFS_SETTOKEN', + source='afs_settoken.c', + deps='samba-util') + diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c index bc25a1722f7..a3e64514552 100644 --- a/nsswitch/wbinfo.c +++ b/nsswitch/wbinfo.c @@ -27,6 +27,7 @@ #include "lib/popt/popt.h" #include "../libcli/auth/libcli_auth.h" #include "lib/cmdline/popt_common.h" +#include "lib/afs/afs_settoken.h" #ifdef DBGC_CLASS #undef DBGC_CLASS diff --git a/source3/include/proto.h b/source3/include/proto.h index 14af2ad6030..285ec7be321 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -35,11 +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_settoken.c */ - -int afs_syscall(int subcall, const char *path, int cmd, char *cmarg, int follow); -bool afs_settoken_str(const char *token_string); - /* The following definitions come from lib/audit.c */ const char *audit_category_str(uint32 category); diff --git a/source3/modules/vfs_afsacl.c b/source3/modules/vfs_afsacl.c index 730098760c9..7a3d5bd255f 100644 --- a/source3/modules/vfs_afsacl.c +++ b/source3/modules/vfs_afsacl.c @@ -24,6 +24,7 @@ #include "../libcli/security/security.h" #include "../libcli/security/dom_sid.h" #include "passdb.h" +#include "lib/afs/afs_settoken.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS diff --git a/source3/utils/net_afs.c b/source3/utils/net_afs.c index 44e5193c884..6049a5cae14 100644 --- a/source3/utils/net_afs.c +++ b/source3/utils/net_afs.c @@ -23,6 +23,7 @@ #include "secrets.h" #include "system/filesys.h" #include "lib/afs/afs_funcs.h" +#include "lib/afs/afs_settoken.h" int net_afs_usage(struct net_context *c, int argc, const char **argv) { diff --git a/source3/wscript_build b/source3/wscript_build index 1f1b75049aa..5995003dc4a 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -468,10 +468,6 @@ bld.SAMBA3_SUBSYSTEM('LIBADS_PRINTER', source='libads/ldap_printer.c', deps='samba-util krb5samba') -bld.SAMBA3_SUBSYSTEM('LIBAFS_SETTOKEN', - source='lib/afs_settoken.c', - deps='samba-util') - bld.SAMBA3_LIBRARY('smbconf', source='''lib/smbconf/smbconf_init.c lib/smbconf/smbconf_reg.c''', -- 2.34.1