FreeBSD Bugzilla – Attachment 146133 Details for
Bug 192900
There is no PAM-independent command to change the login class.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
source for a program named "setloginclass"
setloginclass.c (text/plain), 2.08 KB, created by
Kevin Barry
on 2014-08-21 22:29:41 UTC
(
hide
)
Description:
source for a program named "setloginclass"
Filename:
MIME Type:
Creator:
Kevin Barry
Created:
2014-08-21 22:29:41 UTC
Size:
2.08 KB
patch
obsolete
>#include <stdio.h> >#include <errno.h> >#include <string.h> >#include <unistd.h> >#include <stdlib.h> >#include <sys/types.h> >#include <pwd.h> >#include <login_cap.h> > > >int main(int argc, char *argv[]) >{ > int set_mac = 0x00, index = 1; > > if (index < argc && strcmp(argv[index], "-m") == 0) > { > set_mac = LOGIN_SETMAC; > ++index; > } > > if (argc - index < 1) > { > fprintf(stderr, "%s (-m) [class] [command...]\n", argv[0]); > return 1; > } > > const char *class_name = argv[index++]; > > login_cap_t *class_cap = login_getclassbyname(class_name, NULL); > > if (class_cap && strcmp(class_cap->lc_class, class_name) == 0) > { > if (setusercontext(class_cap, NULL, 0, LOGIN_SETRESOURCES | LOGIN_SETPRIORITY | LOGIN_SETUMASK | LOGIN_SETCPUMASK) < 0) > { > fprintf(stderr, "%s: unable to set login limits for class '%s': %s\n", argv[0], class_name, strerror(errno)); > login_close(class_cap); > return 1; > } > > if (setusercontext(class_cap, NULL, 0, set_mac | LOGIN_SETLOGINCLASS) < 0) > { > fprintf(stderr, "%s: unable to set login class to '%s': %s\n", argv[0], class_name, strerror(errno)); > login_close(class_cap); > return 1; > } > login_close(class_cap); > } > > else > { > fprintf(stderr, "%s: unable to set login class to '%s': %s\n", argv[0], class_name, > class_cap? "login class does not exist" : strerror(errno)); > return 1; > } > > if (argc - index < 1) > { > char *shell = getenv("SHELL"); > if (!shell || !strlen(shell)) > { > struct passwd *user = getpwuid(getuid()); > if (user) shell = user->pw_shell; > endpwent(); > } > if (!shell || !strlen(shell)) > { > fprintf(stderr, "%s: no shell specified\n", argv[0]); > return 1; > } > > char *command[] = { shell, NULL }; > execvp(command[0], command); > fprintf(stderr, "%s: unable to execute '%s': %s\n", argv[0], command[0], strerror(errno)); > } > > else > { > execvp(argv[index], argv + index); > fprintf(stderr, "%s: unable to execute '%s': %s\n", argv[0], argv[2], strerror(errno)); > } > > return 1; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 192900
: 146133 |
146134