Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65cb721c9e | ||
|
|
890eaf6343 | ||
|
|
b04f4d0810 | ||
|
|
55d985a354 | ||
|
|
3791a996e2 | ||
|
|
bf0a5577ac |
No files matched your search
@@ -1,10 +1,10 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
|
© 2016-2026 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||||
© 2015-2016 Markus Teich <markus.teich@stusta.mhn.de>
|
© 2015-2016 Markus Teich <markus.teich@stusta.mhn.de>
|
||||||
© 2014 Dimitris Papastamos <sin@2f30.org>
|
© 2014 Dimitris Papastamos <sin@2f30.org>
|
||||||
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
|
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
|
||||||
© 2014-2016 Laslo Hunhold <dev@frign.de>
|
© 2014-2016 Laslo Hunhold <dev@frign.de>
|
||||||
© 2016-2023 Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ all: slock
|
|||||||
.c.o:
|
.c.o:
|
||||||
${CC} -c ${CFLAGS} $<
|
${CC} -c ${CFLAGS} $<
|
||||||
|
|
||||||
${OBJ}: config.h config.mk arg.h util.h
|
${OBJ}: config.h config.mk util.h
|
||||||
|
|
||||||
config.h:
|
config.h:
|
||||||
cp config.def.h $@
|
cp config.def.h $@
|
||||||
@@ -25,7 +25,7 @@ clean:
|
|||||||
dist: clean
|
dist: clean
|
||||||
mkdir -p slock-${VERSION}
|
mkdir -p slock-${VERSION}
|
||||||
cp -R LICENSE Makefile README slock.1 config.mk \
|
cp -R LICENSE Makefile README slock.1 config.mk \
|
||||||
${SRC} config.def.h arg.h util.h slock-${VERSION}
|
${SRC} config.def.h util.h slock-${VERSION}
|
||||||
tar -cf slock-${VERSION}.tar slock-${VERSION}
|
tar -cf slock-${VERSION}.tar slock-${VERSION}
|
||||||
gzip slock-${VERSION}.tar
|
gzip slock-${VERSION}.tar
|
||||||
rm -rf slock-${VERSION}
|
rm -rf slock-${VERSION}
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copy me if you can.
|
|
||||||
* by 20h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARG_H__
|
|
||||||
#define ARG_H__
|
|
||||||
|
|
||||||
extern char *argv0;
|
|
||||||
|
|
||||||
/* use main(int argc, char *argv[]) */
|
|
||||||
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
|
|
||||||
argv[0] && argv[0][0] == '-'\
|
|
||||||
&& argv[0][1];\
|
|
||||||
argc--, argv++) {\
|
|
||||||
char argc_;\
|
|
||||||
char **argv_;\
|
|
||||||
int brk_;\
|
|
||||||
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
|
|
||||||
argv++;\
|
|
||||||
argc--;\
|
|
||||||
break;\
|
|
||||||
}\
|
|
||||||
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
|
||||||
argv[0][0] && !brk_;\
|
|
||||||
argv[0]++) {\
|
|
||||||
if (argv_ != argv)\
|
|
||||||
break;\
|
|
||||||
argc_ = argv[0][0];\
|
|
||||||
switch (argc_)
|
|
||||||
|
|
||||||
/* Handles obsolete -NUM syntax */
|
|
||||||
#define ARGNUM case '0':\
|
|
||||||
case '1':\
|
|
||||||
case '2':\
|
|
||||||
case '3':\
|
|
||||||
case '4':\
|
|
||||||
case '5':\
|
|
||||||
case '6':\
|
|
||||||
case '7':\
|
|
||||||
case '8':\
|
|
||||||
case '9'
|
|
||||||
|
|
||||||
#define ARGEND }\
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ARGC() argc_
|
|
||||||
|
|
||||||
#define ARGNUMF() (brk_ = 1, estrtonum(argv[0], 0, INT_MAX))
|
|
||||||
|
|
||||||
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
|
||||||
((x), abort(), (char *)0) :\
|
|
||||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
|
||||||
(&argv[0][1]) :\
|
|
||||||
(argc--, argv++, argv[0])))
|
|
||||||
|
|
||||||
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
|
||||||
(char *)0 :\
|
|
||||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
|
||||||
(&argv[0][1]) :\
|
|
||||||
(argc--, argv++, argv[0])))
|
|
||||||
|
|
||||||
#define LNGARG() &argv[0][0]
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# slock version
|
# slock version
|
||||||
VERSION = 1.6
|
VERSION = 1.7
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.Dd October 6, 2023
|
.Dd September 5, 2026
|
||||||
.Dt SLOCK 1
|
.Dt SLOCK 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -7,14 +7,9 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl v
|
.Op Fl v
|
||||||
.Op Ar cmd Op Ar arg ...
|
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
is a simple X screen locker.
|
is a simple X screen locker.
|
||||||
If provided,
|
|
||||||
.Ar cmd
|
|
||||||
is executed after the screen has been locked.
|
|
||||||
.Pp
|
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl v
|
.It Fl v
|
||||||
@@ -22,10 +17,6 @@ Print version information to stdout and exit.
|
|||||||
.El
|
.El
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Ex -std
|
.Ex -std
|
||||||
.Sh EXAMPLES
|
|
||||||
$
|
|
||||||
.Nm
|
|
||||||
/usr/sbin/s2ram
|
|
||||||
.Sh SECURITY CONSIDERATIONS
|
.Sh SECURITY CONSIDERATIONS
|
||||||
To make sure a locked screen can not be bypassed by switching VTs
|
To make sure a locked screen can not be bypassed by switching VTs
|
||||||
or killing the X server with Ctrl+Alt+Backspace, it is recommended
|
or killing the X server with Ctrl+Alt+Backspace, it is recommended
|
||||||
|
|||||||
@@ -13,14 +13,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <spawn.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include "arg.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
char *argv0;
|
char *argv0;
|
||||||
@@ -181,10 +179,13 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
|||||||
passwd[--len] = '\0';
|
passwd[--len] = '\0';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (num && !iscntrl((int)buf[0]) &&
|
if (num && !iscntrl((unsigned char)buf[0]) &&
|
||||||
(len + num < sizeof(passwd))) {
|
(len + num < sizeof(passwd))) {
|
||||||
memcpy(passwd + len, buf, num);
|
memcpy(passwd + len, buf, num);
|
||||||
len += num;
|
len += num;
|
||||||
|
} else if (buf[0] == '\025') { /* ctrl-u clears input */
|
||||||
|
explicit_bzero(&passwd, sizeof(passwd));
|
||||||
|
len = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -301,7 +302,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
die("usage: slock [-v] [cmd [arg ...]]\n");
|
die("usage: slock [-v]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -316,13 +317,12 @@ main(int argc, char **argv) {
|
|||||||
Display *dpy;
|
Display *dpy;
|
||||||
int s, nlocks, nscreens;
|
int s, nlocks, nscreens;
|
||||||
|
|
||||||
ARGBEGIN {
|
if (argc > 1 && !strcmp(argv[1], "-v")) {
|
||||||
case 'v':
|
|
||||||
puts("slock-"VERSION);
|
puts("slock-"VERSION);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
} else if (argc > 1) {
|
||||||
usage();
|
usage();
|
||||||
} ARGEND
|
}
|
||||||
|
|
||||||
/* validate drop-user and -group */
|
/* validate drop-user and -group */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@@ -375,17 +375,6 @@ main(int argc, char **argv) {
|
|||||||
if (nlocks != nscreens)
|
if (nlocks != nscreens)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* run post-lock command */
|
|
||||||
if (argc > 0) {
|
|
||||||
pid_t pid;
|
|
||||||
extern char **environ;
|
|
||||||
int err = posix_spawnp(&pid, argv[0], NULL, NULL, argv, environ);
|
|
||||||
if (err) {
|
|
||||||
die("slock: failed to execute post-lock command: %s: %s\n",
|
|
||||||
argv[0], strerror(err));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* everything is now blank. Wait for the correct password */
|
/* everything is now blank. Wait for the correct password */
|
||||||
readpw(dpy, &rr, locks, nscreens, hash);
|
readpw(dpy, &rr, locks, nscreens, hash);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user