lib/username.c

ソースコードを見る。

関数

static struct passwd * uname_string_combinations (char *s, TALLOC_CTX *mem_ctx, struct passwd *(*fn)(TALLOC_CTX *mem_ctx, const char *), int N)
static struct passwd * uname_string_combinations2 (char *s, TALLOC_CTX *mem_ctx, int offset, struct passwd *(*fn)(TALLOC_CTX *mem_ctx, const char *), int N)
char * get_user_home_dir (const char *user)
static struct passwd * Get_Pwnam_internals (TALLOC_CTX *mem_ctx, const char *user, char *user2)
passwd * Get_Pwnam_alloc (TALLOC_CTX *mem_ctx, const char *user)
passwd * Get_Pwnam (const char *user)

変数

static struct passwd * Get_Pwnam_ret = NULL


関数

static struct passwd * uname_string_combinations ( char *  s,
TALLOC_CTX mem_ctx,
struct passwd *(*)(TALLOC_CTX *mem_ctx, const char *)  fn,
int  N 
) [static]

username.c214 行で定義されています。

参照先 uname_string_combinations2().

参照元 Get_Pwnam_internals().

00217 {
00218         int n;
00219         struct passwd *ret;
00220 
00221         for (n=1;n<=N;n++) {
00222                 ret = uname_string_combinations2(s,mem_ctx,0,fn,n);
00223                 if(ret)
00224                         return(ret);
00225         }  
00226         return(NULL);
00227 }

static struct passwd * uname_string_combinations2 ( char *  s,
TALLOC_CTX mem_ctx,
int  offset,
struct passwd *(*)(TALLOC_CTX *mem_ctx, const char *)  fn,
int  N 
) [static]

username.c181 行で定義されています。

参照先 cfnislower_ascii()lentoupper_ascii().

参照元 uname_string_combinations().

00185 {
00186         ssize_t len = (ssize_t)strlen(s);
00187         int i;
00188         struct passwd *ret;
00189 
00190         if (N <= 0 || offset >= len)
00191                 return(fn(mem_ctx, s));
00192 
00193         for (i=offset;i<(len-(N-1));i++) {
00194                 char c = s[i];
00195                 if (!islower_ascii((int)c))
00196                         continue;
00197                 s[i] = toupper_ascii(c);
00198                 ret = uname_string_combinations2(s, mem_ctx, i+1, fn, N-1);
00199                 if(ret)
00200                         return(ret);
00201                 s[i] = c;
00202         }
00203         return(NULL);
00204 }

char* get_user_home_dir ( const char *  user  ) 

username.c36 行で定義されています。

参照先 Get_Pwnam().

参照元 alloc_sub_advanced()automount_path()find_service()lp_add_auto_services().

00037 {
00038         static struct passwd *pass;
00039 
00040         /* Ensure the user exists. */
00041 
00042         pass = Get_Pwnam(user);
00043 
00044         if (!pass)
00045                 return(NULL);
00046         /* Return home directory from struct passwd. */
00047 
00048         return(pass->pw_dir);      
00049 }

static struct passwd* Get_Pwnam_internals ( TALLOC_CTX mem_ctx,
const char *  user,
char *  user2 
) [static]

username.c61 行で定義されています。

参照先 getpwnam_alloc()strlower_m()strupper_m()uname_string_combinations().

参照元 Get_Pwnam_alloc().

00063 {
00064         struct passwd *ret = NULL;
00065 
00066         if (!user2 || !(*user2))
00067                 return(NULL);
00068 
00069         if (!user || !(*user))
00070                 return(NULL);
00071 
00072         /* Try in all lower case first as this is the most 
00073            common case on UNIX systems */
00074         strlower_m(user2);
00075         DEBUG(5,("Trying _Get_Pwnam(), username as lowercase is %s\n",user2));
00076         ret = getpwnam_alloc(mem_ctx, user2);
00077         if(ret)
00078                 goto done;
00079 
00080         /* Try as given, if username wasn't originally lowercase */
00081         if(strcmp(user, user2) != 0) {
00082                 DEBUG(5,("Trying _Get_Pwnam(), username as given is %s\n",
00083                          user));
00084                 ret = getpwnam_alloc(mem_ctx, user);
00085                 if(ret)
00086                         goto done;
00087         }
00088 
00089         /* Try as uppercase, if username wasn't originally uppercase */
00090         strupper_m(user2);
00091         if(strcmp(user, user2) != 0) {
00092                 DEBUG(5,("Trying _Get_Pwnam(), username as uppercase is %s\n",
00093                          user2));
00094                 ret = getpwnam_alloc(mem_ctx, user2);
00095                 if(ret)
00096                         goto done;
00097         }
00098 
00099         /* Try all combinations up to usernamelevel */
00100         strlower_m(user2);
00101         DEBUG(5,("Checking combinations of %d uppercase letters in %s\n",
00102                  lp_usernamelevel(), user2));
00103         ret = uname_string_combinations(user2, mem_ctx, getpwnam_alloc,
00104                                         lp_usernamelevel());
00105 
00106 done:
00107         DEBUG(5,("Get_Pwnam_internals %s find user [%s]!\n",ret ?
00108                  "did":"didn't", user));
00109 
00110         return ret;
00111 }

struct passwd* Get_Pwnam_alloc ( TALLOC_CTX mem_ctx,
const char *  user 
)

username.c119 行で定義されています。

参照先 Get_Pwnam_internals().

参照元 Get_Pwnam()pdb_default_create_user()pdb_get_group_sid()smb_getpwnam().

00120 {
00121         fstring user2;
00122         struct passwd *ret;
00123 
00124         if ( *user == '\0' ) {
00125                 DEBUG(10,("Get_Pwnam: empty username!\n"));
00126                 return NULL;
00127         }
00128 
00129         fstrcpy(user2, user);
00130 
00131         DEBUG(5,("Finding user %s\n", user));
00132 
00133         ret = Get_Pwnam_internals(mem_ctx, user, user2);
00134         
00135         return ret;  
00136 }

struct passwd* Get_Pwnam ( const char *  user  ) 

username.c143 行で定義されています。

参照先 Get_Pwnam_alloc().

参照元 add_session_user()alloc_sub_basic()authorise_login()change_oem_password()check_unix_security()fetch_account_info()get_user_home_dir()idmap_nss_sids_to_unixids()lookup_global_sam_rid()make_connection_snum()set_user_info_23()set_user_info_pw().

00144 {
00145         struct passwd *ret;
00146 
00147         ret = Get_Pwnam_alloc(NULL, user);
00148         
00149         /* This call used to just return the 'passwd' static buffer.
00150            This could then have accidental reuse implications, so 
00151            we now malloc a copy, and free it in the next use.
00152 
00153            This should cause the (ab)user to segfault if it 
00154            uses an old struct. 
00155            
00156            This is better than useing the wrong data in security
00157            critical operations.
00158 
00159            The real fix is to make the callers free the returned 
00160            malloc'ed data.
00161         */
00162 
00163         if (Get_Pwnam_ret) {
00164                 TALLOC_FREE(Get_Pwnam_ret);
00165         }
00166         
00167         Get_Pwnam_ret = ret;
00168 
00169         return ret;  
00170 }


変数

struct passwd* Get_Pwnam_ret = NULL [static]

username.c59 行で定義されています。


Sambaに対してSat Aug 29 21:23:39 2009に生成されました。  doxygen 1.4.7