From 5ca9317d4cb2da0d79965922f7d4c8709dafffa7 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 20 Oct 2004 15:41:05 +0000 Subject: [PATCH] A few more tweaks to sysacls.c and sysacls.h. --- acls.diff | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/acls.diff b/acls.diff index 01be4c7..022192a 100644 --- a/acls.diff +++ b/acls.diff @@ -1338,12 +1338,11 @@ ACLs to a non-ACL-supporting disk should complain. return; } ---- orig/lib/sysacls.c 2004-10-20 08:06:39 -+++ lib/sysacls.c 2004-10-20 08:06:39 -@@ -0,0 +1,3218 @@ +--- orig/lib/sysacls.c 2004-10-20 15:35:58 ++++ lib/sysacls.c 2004-10-20 15:35:58 +@@ -0,0 +1,3217 @@ +/* -+ Unix SMB/Netbios implementation. -+ Version 2.2. ++ Unix SMB/CIFS implementation. + Samba system utilities for ACL support. + Copyright (C) Jeremy Allison 2000. + @@ -1371,6 +1370,18 @@ ACLs to a non-ACL-supporting disk should complain. + free(mem); +} + ++char *uidtoname(uid_t uid) ++{ ++ static char idbuf[12]; ++ struct passwd *pw; ++ ++ if ((pw = getpwuid(uid)) == NULL) { ++ slprintf(idbuf, sizeof(idbuf)-1, "%ld", (long)uid); ++ return idbuf; ++ } ++ return pw->pw_name; ++} ++ +/* + This file wraps all differing system ACL interfaces into a consistent + one based on the POSIX interface. It also returns the correct errors @@ -1995,13 +2006,7 @@ ACLs to a non-ACL-supporting disk should complain. + break; + + case SMB_ACL_USER: -+ if ((pw = getpwuid(ap->a_id)) == NULL) { -+ snprintf(idbuf, sizeof(idbuf)-1, "%ld", -+ (long)ap->a_id); -+ id = idbuf; -+ } else { -+ id = pw->pw_name; -+ } ++ id = uidtoname(ap->a_id); + case SMB_ACL_USER_OBJ: + tag = "user"; + break; @@ -2554,7 +2559,7 @@ ACLs to a non-ACL-supporting disk should complain. + * can use the relative path. + */ + -+ return sys_acl_get_file(dos_to_unix_static(fsp->fsp_name), SMB_ACL_TYPE_ACCESS); ++ return sys_acl_get_file(fsp->fsp_name, SMB_ACL_TYPE_ACCESS); +} + +int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d) @@ -2632,13 +2637,7 @@ ACLs to a non-ACL-supporting disk should complain. + break; + + case SMB_ACL_USER: -+ if ((pw = getpwuid(ap->a_id)) == NULL) { -+ snprintf(idbuf, sizeof(idbuf)-1, "%ld", -+ (long)ap->a_id); -+ id = idbuf; -+ } else { -+ id = pw->pw_name; -+ } ++ id = uidtoname(ap->a_id); + case SMB_ACL_USER_OBJ: + tag = "user"; + break; @@ -3244,7 +3243,7 @@ ACLs to a non-ACL-supporting disk should complain. + * can use the relative path. + */ + -+ return sys_acl_set_file(dos_to_unix_static(fsp->fsp_name), SMB_ACL_TYPE_ACCESS, acl_d); ++ return sys_acl_set_file(fsp->fsp_name, SMB_ACL_TYPE_ACCESS, acl_d); +} + +int sys_acl_delete_def_file(const char *path) @@ -4453,13 +4452,13 @@ ACLs to a non-ACL-supporting disk should complain. +SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type) +{ + errno = ENOSYS; -+ return 0; ++ return (SMB_ACL_T)NULL; +} + +SMB_ACL_T sys_acl_get_fd(int fd) +{ + errno = ENOSYS; -+ return 0; ++ return (SMB_ACL_T)NULL; +} + +int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset) @@ -4559,10 +4558,11 @@ ACLs to a non-ACL-supporting disk should complain. +} + +#endif /* No ACLs. */ ---- orig/lib/sysacls.h 2004-10-20 08:06:45 -+++ lib/sysacls.h 2004-10-20 08:06:45 -@@ -0,0 +1,24 @@ +--- orig/lib/sysacls.h 2004-10-20 15:31:22 ++++ lib/sysacls.h 2004-10-20 15:31:22 +@@ -0,0 +1,25 @@ +#define Realloc(mem, cnt) realloc_array((mem), char, (cnt)) ++#define slprintf snprintf + +int sys_acl_get_entry(SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p); -- 2.34.1