Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- xtrlock.c 2014-01-07 14:20:33.000000000 +0000
- +++ xtrlock.c.new 2015-11-27 16:20:42.148166109 +0000
- @@ -37,6 +37,9 @@
- #include <ctype.h>
- #include <values.h>
- +/* required for custom passwd prompt --tetris11 */
- +#include <unistd.h>
- +
- #ifdef SHADOW_PWD
- #include <shadow.h>
- #endif
- @@ -54,7 +57,15 @@
- #define GOODWILLPORTION 0.3
- struct passwd *pw;
- +
- +int c_pass = 0; /* custom_password flag */
- +
- int passwordok(const char *s) {
- +
- + if ( c_pass == 1 ) {
- + return strcmp(s+1, pw->pw_passwd); /* skip first character to work --tetris11 */
- + }
- +
- #if 0
- char key[3];
- char *encr;
- @@ -82,39 +93,71 @@
- Pixmap csr_source,csr_mask;
- XColor csr_fg, csr_bg, dummy, black;
- int ret, screen, blank = 0;
- + char *custom_passwd = 0;
- +
- +#define USAGE_EXIT \
- + fprintf(stderr,"xtrlock (version %s); usage: xtrlock [-b] [-p]\n", program_version); \
- + exit(1);
- +
- +#define CUSTOM_PROMPT "custom passphrase: "
- +
- #ifdef SHADOW_PWD
- struct spwd *sp;
- #endif
- struct timeval tv;
- int tvt, gs;
- - if ((argc == 2) && (strcmp(argv[1], "-b") == 0)) {
- - blank = 1;
- - } else if (argc > 1) {
- - fprintf(stderr,"xtrlock (version %s); usage: xtrlock [-b]\n",
- - program_version);
- - exit(1);
- + if (argc == 2){
- + if (strcmp(argv[1], "-b") == 0 ) {
- + blank = 1;
- + }
- + else if (strcmp(argv[1],"-p") == 0 ) {
- + c_pass = 1;
- + custom_passwd = getpass(CUSTOM_PROMPT);
- + }
- + else {USAGE_EXIT}
- }
- -
- + else if (argc == 3) {
- + if (\
- + (strcmp(argv[1], "-b") == 0 ) && (strcmp(argv[2], "-p") == 0) || \
- + (strcmp(argv[1], "-p") == 0 ) && (strcmp(argv[2], "-b") == 0)\
- + ) {
- + blank = c_pass = 1;
- + custom_passwd = getpass(CUSTOM_PROMPT);
- + }
- + else {USAGE_EXIT}
- + }
- + else if (argc > 1) {USAGE_EXIT}
- +
- +
- +
- errno=0; pw= getpwuid(getuid());
- - if (!pw) { perror("password entry for uid not found"); exit(1); }
- +
- + if (c_pass == 1) {
- + /* custom password bypasses gid uid checks, but still requires
- + a valid pw struct --tetris11 */
- + pw->pw_passwd = custom_passwd;
- + }
- + else {
- + if (!pw) { perror("password entry for uid not found"); exit(1); }
- #ifdef SHADOW_PWD
- - sp = getspnam(pw->pw_name);
- - if (sp)
- - pw->pw_passwd = sp->sp_pwdp;
- - endspent();
- + sp = getspnam(pw->pw_name);
- + if (sp)
- + pw->pw_passwd = sp->sp_pwdp;
- + endspent();
- #endif
- - /* logically, if we need to do the following then the same
- - applies to being installed setgid shadow.
- - we do this first, because of a bug in linux. --jdamery */
- - if (setgid(getgid())) { perror("setgid"); exit(1); }
- - /* we can be installed setuid root to support shadow passwords,
- - and we don't need root privileges any longer. --marekm */
- - if (setuid(getuid())) { perror("setuid"); exit(1); }
- -
- - if (strlen(pw->pw_passwd) < 13) {
- - fputs("password entry has no pwd\n",stderr); exit(1);
- + /* logically, if we need to do the following then the same
- + applies to being installed setgid shadow.
- + we do this first, because of a bug in linux. --jdamery */
- + if (setgid(getgid())) { perror("setgid"); exit(1); }
- + /* we can be installed setuid root to support shadow passwords,
- + and we don't need root privileges any longer. --marekm */
- + if (setuid(getuid())) { perror("setuid"); exit(1); }
- +
- + if (strlen(pw->pw_passwd) < 13) {
- + fputs("password entry has no pwd\n",stderr); exit(1);
- + }
- }
- display= XOpenDisplay(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement