Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from google:master #24

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ IMPORTANT: Make sure your desktop environment does not launch any other locker,
be it via autostart file or its own configuration, as multiple screen lockers
may interfere with each other. You have been warned!

## Authentication on resume from suspend/hibernate

To have the authentication process start up without a keypress when
the system exits suspend/hibernate, arrange for the system to send the
`SIGUSR2` signal to the XSecureLock process.

For example, you can copy the following script to the file
`/usr/lib/systemd/system-sleep/xsecurelock`:

```
#!/bin/bash
if [[ "$1" = "post" ]] ; then
pkill -x -USR2 xsecurelock
fi
exit 0
```

Don't forget to mark the script executable.

# Automatic Locking

To automatically lock the screen after some time of inactivity, use
Expand Down Expand Up @@ -234,6 +253,8 @@ Options to XSecureLock can be passed by environment variables:
the screen saver.
* `XSECURELOCK_AUTH_WARNING_COLOR`: specifies the X11 color (see manpage of
XParseColor) for the warning text of the auth dialog.
* `XSECURELOCK_BACKGROUND_COLOR`: specifies the X11 color (see manpage
of XParseColor) for the background of the main and saver windows.
* `XSECURELOCK_BLANK_TIMEOUT`: specifies the time (in seconds) before telling
X11 to fully blank the screen; a negative value disables X11 blanking. The
time is measured since the closing of the auth window or xsecurelock
Expand Down Expand Up @@ -403,6 +424,8 @@ Options to XSecureLock can be passed by environment variables:
* `XSECURELOCK_SHOW_HOSTNAME`: whether to show the hostname on the login
screen of `auth_x11`. Possible values are 0 for not showing the
hostname, 1 for showing the short form, and 2 for showing the long form.
* `XSECURELOCK_SHOW_KEYBOARD_LAYOUT`: whether to show the name of the current
keyboard layout. Enabled by default.
* `XSECURELOCK_SHOW_USERNAME`: whether to show the username on the login
screen of `auth_x11`.
* `XSECURELOCK_SINGLE_AUTH_WINDOW`: whether to show only a single auth window
Expand All @@ -417,6 +440,11 @@ Options to XSecureLock can be passed by environment variables:
locking) when above xss-lock command line is used. Should be at least as
large as the period time set using "xset s". Also used by `wait_nonidle` to
know when to assume dimming and waiting has finished and exit.
* `XSECURELOCK_SAVER_DELAY_MS`: Milliseconds to wait after starting
children process and before mapping windows to let children be
ready to display and reduce the black flash.
* `XSECURELOCK_SAVER_STOP_ON_BLANK`: specifies if saver is stopped
when screen is blanked (DPMS or XSS) to save power.
* `XSECURELOCK_XSCREENSAVER_PATH`: Location where XScreenSaver hacks are
installed for use by `saver_xscreensaver`.

Expand Down Expand Up @@ -500,7 +528,8 @@ The screen saver module is a separate executable, whose name must start with
`saver_` and be installed together with the included `auth_` modules (default
location: `/usr/local/libexec/xsecurelock/helpers`).

* Input: none.
* Input: receives the 0-based index of the screen saver (remember: one saver
is started per display by the multiplexer) via `$XSCREENSAVER_SAVER_INDEX`.
* Output: it may draw on or create windows below `$XSCREENSAVER_WINDOW`.
* Exit condition: the saver child will receive SIGTERM when the user wishes to
unlock the screen. It should exit promptly.
Expand Down
33 changes: 16 additions & 17 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

define([thisversion],[1.7.0])
define([nextversion],[1.7.0])
AC_INIT([xsecurelock],thisversion,[[email protected]])
define([thisversion],[1.9.0])
define([nextversion],[1.9.0])
AC_INIT([xsecurelock],[thisversion],[[email protected]])
AM_INIT_AUTOMAKE([-Wall subdir-objects foreign])
AC_PROG_CC
AC_PROG_CC_C99

AC_DEFUN([RP_TRY_CC_FLAG], [
AC_MSG_CHECKING([whether the compiler supports $1])
Expand All @@ -43,14 +42,14 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
LDFLAGS=$saved_LDFLAGS])

AC_CHECK_HEADER(X11/Xlib.h,
[], [AC_ERROR([X includes not found.])])
[], [AC_MSG_ERROR(X includes not found.)])
AC_CHECK_LIB(X11, XOpenDisplay,
[], [AC_ERROR([X library not found.])])
[], [AC_MSG_ERROR(X library not found.)])
AC_CHECK_LIB(Xmuu, XmuClientWindow,
[], [AC_CHECK_LIB(Xmu, XmuClientWindow,
[], [AC_ERROR([Xmuu or Xmu library not found.])])])
[], [AC_MSG_ERROR(Xmuu or Xmu library not found.)])])
AC_CHECK_LIB(m, sqrt,
[], [AC_ERROR([Math library not found.])])
[], [AC_MSG_ERROR(Math library not found.)])

# RP_SEARCH_LIBS(sym, lib, macro, flag, default, description)
AC_DEFUN([RP_SEARCH_LIBS], [
Expand Down Expand Up @@ -102,7 +101,7 @@ AC_DEFUN([RP_CHECK_MODULE], [
[AC_MSG_ERROR([--with-$4 was enabled, but test for $4 failed])])])])
AM_CONDITIONAL([$3], [test x$have_$4 = xtrue])])

# The DPMS extension is used to save power of the screen when turned off. Saves
# The DPMS extension is used to save power of the screen when turned off. Saves
# electric power.
RP_SEARCH_LIBS(DPMSQueryExtension, Xext,
[HAVE_DPMS_EXT], [dpms], [check],
Expand Down Expand Up @@ -195,9 +194,9 @@ RP_SEARCH_PROG(pandoc, [$PATH],
[HAVE_PANDOC], [pandoc], [check],
[Use pandoc to generate man pages])

RP_SEARCH_PROG(slidescreen, /usr/lib/xscreensaver,
RP_SEARCH_PROG(slidescreen, [/usr/libexec/xscreensaver:/usr/lib/xscreensaver],
[HAVE_XSCREENSAVER], [xscreensaver], [check],
[Install saver_xscreensaver (specify --with-xscreensaver=/usr/lib/xscreensaver to set the saver plugin directory to use)])
[Install saver_xscreensaver (specify --with-xscreensaver=/usr/libexec/xscreensaver to set the saver plugin directory to use)])
# However, all we really want is the directory name...
path_to_xscreensaver=${path_to_xscreensaver%/slidescreen}

Expand All @@ -206,7 +205,7 @@ enable_pam_check_account_type=no

AS_IF([test x$have_pam = xtrue], [
AC_ARG_WITH([pam_service_name],
AC_HELP_STRING([--with-pam-service-name],
AS_HELP_STRING([--with-pam-service-name],
[The name of the PAM service that xsecurelock's
auth helpers will authenticate as by default.
This flag is mandatory. Be sure to verify that
Expand All @@ -218,7 +217,7 @@ AS_IF([test x$have_pam = xtrue], [
[AC_MSG_WARN([/etc/pam.d/$pam_service_name doesn't exist. Sure?])])

AC_ARG_ENABLE([pam_check_account_type],
AC_HELP_STRING([--enable-pam-check-account-type],
AS_HELP_STRING([--enable-pam-check-account-type],
[Enable checking of PAM accounting result. Only
enable this if accounting is properly configured
on your system; especially keep this disabled if
Expand All @@ -230,7 +229,7 @@ AS_IF([test x$have_pam = xtrue], [
])

AC_ARG_WITH([default_auth_module],
AC_HELP_STRING([--with-default-auth-module],
AS_HELP_STRING([--with-default-auth-module],
[The default authentication module to use when none
was specified. Can be overridden via the
XSECURELOCK_AUTH environment variable or a command
Expand All @@ -241,7 +240,7 @@ AC_ARG_WITH([default_auth_module],
AC_MSG_NOTICE([Configured default auth module: $auth_executable])

AC_ARG_WITH([default_authproto_module],
AC_HELP_STRING([--with-default-authproto-module],
AS_HELP_STRING([--with-default-authproto-module],
[The default authentication protocol module to use when none was
specified. Can be overridden via the
XSECURELOCK_AUTHPROTO environment variable. By
Expand All @@ -263,7 +262,7 @@ AC_ARG_WITH([default_authproto_module],
AC_MSG_NOTICE([Configured default authproto module: $authproto_executable])

AC_ARG_WITH([default_global_saver_module],
AC_HELP_STRING([--with-default-global-saver-module],
AS_HELP_STRING([--with-default-global-saver-module],
[The default global saver module to use when none was
specified. Can be overridden via the
XSECURELOCK_GLOBAL_SAVER environment variable.]),
Expand All @@ -274,7 +273,7 @@ AC_MSG_NOTICE([Configured default global saver module: ]dnl
[$global_saver_executable])

AC_ARG_WITH([default_saver_module],
AC_HELP_STRING([--with-default-saver-module],
AS_HELP_STRING([--with-default-saver-module],
[The default per-screen saver module to use when none
was specified. Can be overridden via the
XSECURELOCK_SAVER environment variable.]),
Expand Down
36 changes: 21 additions & 15 deletions helpers/auth_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ static int single_auth_window = 0;
int per_monitor_windows_dirty = 1;

#ifdef HAVE_XKB_EXT
//! If set, we show Xkb keyboard layout name.
int show_keyboard_layout = 1;
//! If set, we show Xkb lock/latch status rather than Xkb indicators.
int show_locks_and_latches = 0;
#endif
Expand Down Expand Up @@ -447,23 +449,25 @@ const char *GetIndicators(int *warning, int *have_multiple_layouts) {
p += n;

int have_output = 0;
Atom layouta = xkb->names->groups[state.group]; // Human-readable.
if (layouta == None) {
layouta = xkb->names->symbols; // Machine-readable fallback.
}
if (layouta != None) {
char *layout = XGetAtomName(display, layouta);
n = strlen(layout);
if (n >= sizeof(buf) - (p - buf)) {
Log("Not enough space to store layout name '%s'", layout);
if (show_keyboard_layout) {
Atom layouta = xkb->names->groups[state.group]; // Human-readable.
if (layouta == None) {
layouta = xkb->names->symbols; // Machine-readable fallback.
}
if (layouta != None) {
char *layout = XGetAtomName(display, layouta);
n = strlen(layout);
if (n >= sizeof(buf) - (p - buf)) {
Log("Not enough space to store layout name '%s'", layout);
XFree(layout);
XkbFreeKeyboard(xkb, 0, True);
return "";
}
memcpy(p, layout, n);
XFree(layout);
XkbFreeKeyboard(xkb, 0, True);
return "";
p += n;
have_output = 1;
}
memcpy(p, layout, n);
XFree(layout);
p += n;
have_output = 1;
}

if (show_locks_and_latches) {
Expand Down Expand Up @@ -1611,6 +1615,8 @@ int main(int argc_local, char **argv_local) {
single_auth_window = GetIntSetting("XSECURELOCK_SINGLE_AUTH_WINDOW", 0);
auth_cursor_blink = GetIntSetting("XSECURELOCK_AUTH_CURSOR_BLINK", 1);
#ifdef HAVE_XKB_EXT
show_keyboard_layout =
GetIntSetting("XSECURELOCK_SHOW_KEYBOARD_LAYOUT", 1);
show_locks_and_latches =
GetIntSetting("XSECURELOCK_SHOW_LOCKS_AND_LATCHES", 0);
#endif
Expand Down
4 changes: 1 addition & 3 deletions helpers/saver_multiplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ static void WatchSavers(void) {
}

static void SpawnSavers(Window parent, int argc, char* const* argv) {
XSetWindowAttributes attrs = {0};
attrs.background_pixel = BlackPixel(display, DefaultScreen(display));
for (size_t i = 0; i < num_monitors; ++i) {
windows[i] =
XCreateWindow(display, parent, monitors[i].x, monitors[i].y,
monitors[i].width, monitors[i].height, 0, CopyFromParent,
InputOutput, CopyFromParent, CWBackPixel, &attrs);
InputOutput, CopyFromParent, 0, NULL);
SetWMProperties(display, windows[i], "xsecurelock",
"saver_multiplex_screen", argc, argv);
XMapRaised(display, windows[i]);
Expand Down
Loading