getpwnam

how to do getpwnam/getpwuid etc in tcl

て烟熏妆下的殇ゞ 提交于 2019-12-24 07:03:11
问题 does tcl have a standard way of doing NSS lookups (getpwnam, setpwent,...) 回答1: Tcl doesn't expose those as APIs (it doesn't really use them internally either) but the TclX extension package does support exactly what you want I believe. For example: package require TclX set uid [id convert user $tcl_platform(user)] puts "Your userid is $uid and you are a member of these groups: [id groups]" If you're using ActiveTcl, you've definitely got the TclX package available (either already installed

Why is getpwnam() always returning root information in a function?

余生颓废 提交于 2019-12-08 18:18:26
I wrote a simple program that calls getpwnam() on a username, passes that username to a function, and then calls getpwnam() again. For some reason, I always get the passwd information for root inside the function. #include <sys/types.h> #include <pwd.h> #include <stdio.h> void printuser(char *username) { printf("USERNAME2: %s\n", username); struct passwd *user_info = getpwnam(username); printf("USERNAME3: %s\n", username); printf("USERNAME4: %s\n", user_info->pw_name); } int main(int argc, char *argv[]) { struct passwd *user_info = getpwnam(argv[1]); printf("USERNAME1: %s\n", user_info->pw

Why is getpwnam() always returning root information in a function?

◇◆丶佛笑我妖孽 提交于 2019-12-08 04:23:55
问题 I wrote a simple program that calls getpwnam() on a username, passes that username to a function, and then calls getpwnam() again. For some reason, I always get the passwd information for root inside the function. #include <sys/types.h> #include <pwd.h> #include <stdio.h> void printuser(char *username) { printf("USERNAME2: %s\n", username); struct passwd *user_info = getpwnam(username); printf("USERNAME3: %s\n", username); printf("USERNAME4: %s\n", user_info->pw_name); } int main(int argc,