* more consistency in the ui, updated documentation

* added -auth md5:file=<filename>
* added -auth sha1:file=<filename>
* rename -cursor font to -cursor glyph

--HG--
extra : convert_revision : svn%3Aeebe1cee-a9af-4fe4-bd26-ad572b19c5ab/trunk%4027
This commit is contained in:
mathias 2005-05-23 23:23:13 +00:00
parent 809a804c97
commit eee940c36c
12 changed files with 245 additions and 116 deletions

View file

@ -1,5 +1,12 @@
Version 1.0
2005-05-24:
* more consistency in the ui, updated documentation
* added -auth md5:file=<filename>
* added -auth sha1:file=<filename>
* rename -cursor font to -cursor glyph
2005-05-23:
* added -bg image:shade=<perc>

View file

@ -1,7 +1,7 @@
ALOCK(1)
========
Mathias Gumz <akira@fluxbox.org>
v0.5, ?? May 2005
v1.0, ?? May 2005
NAME
----
@ -13,11 +13,11 @@ SYNOPSIS
DESCRIPTION
-----------
alock locks the X server till the user enters a password at the
'alock' locks the X server till the user enters a password at the
keyboard. If the authentification was successful the X server is
unlocked and the user can continue to work.
alock does not provide fancy animations like 'xlock' and 'xscreensaver'
'alock' does not provide fancy animations like 'xlock' and 'xscreensaver'
and never will. Its just for locking the current X session.
OPTIONS
@ -30,36 +30,52 @@ OPTIONS
-auth type:options ::
Define the type of the authentification, depends strongly on
how alock was built:
- list - Displays a list of available types
- passwd - Tries to authentificate against the users system-password.
On systems using 'shadow' alock needs the suid-flag set.
- pam - Tries to authentificate against the users system-password
using the 'pam-login'-module.
- md5:hash - alock creates a md5-hash from the entered unlockpassword
and compares it with the hash provided as option
- sha1:hash - alock creates a sha1-hash from the entered unlockpassword
and compares it with the hash provided as option
- none - Every 'password' is valid
- list - Displays a list of available types
- passwd - Tries to authentificate against the users system-password.
On systems using 'shadow' alock needs the suid-flag set.
- pam - Tries to authentificate against the users system-password
using the 'pam-login'-module.
- md5 - alock creates a md5-hash from the entered unlockpassword and compares it with the hash provided
* hash=<hash> - use <hash> as reference
* file=<filename> - use content of <filename> as reference
- sha1 - alock creates a sha1-hash from the entered unlockpassword and compares it with the hash provided
* hash=<hash> - use <hash> as reference
* file=<filename> - use <filename> as reference
-bg type:options ::
Define the type of alock should handle the background:
- list - Displays a list of available types
- none - You can see everything like it is
- blank:color - Fill the background with color
- shade:shade=<perc>,color=<color> - Dims content of the screen and
recolors it.
- image:name,center,scale,tile,color=<color>,shade=<perc> - Use the image <name> and puts it as
the background.
- list - Displays a list of available types
- none - You can see everything like it is
- blank - Fill the background with color
* color=<color> - Use <color>
- shade - Dims content of the screen and recolors it.
* shade=<perc> - Valid from 1 to 99
* color=<color> - Use <color>
- image - Use the image <filename> and puts it as the background
* file=<filename>
* center
* scale
* tile
* color=<color> - Use <color>
* shade=<perc> - Valid from 1 to 99
-cursor type:options ::
Define the look-a-like of the cursor/mouse pointer:
- list - Displays a list of available types
- theme:name,bg=<color>,fg=<color> - Use the given internal cursor, if name == "list" it lists
the available themes
- font:name,bg=<color>,fg=<color> - Use the given glyph of the "cursor"-font, if name ==
"list" it lists the available glyphnames
- xcursor:file - Use the given cursorfile in xcursor-format
- none - no change to the current cursor
- list - Displays a list of available types
- theme - Use the given internal cursor
* list - Display all possible themes
* name=<name>
* bg=<color> - Use forground-color
* fg=<color> - Use background-color
- glyph - Use the given glyph of the "cursor"-font
* list - Display all possible glyph-names
* name=<name>
* bg=<color>
* fg=<color>
- xcursor - Use the given <filename> in xcursor-format
* file=<filename>
- none - No change to the current cursor
AUTHOR
------
@ -69,7 +85,7 @@ RESOURCES
---------
Web site: http://darkshed.net
Other lockers::
Other lockers ::
- xlockmore http://www.tux.org/~bagleyd/xlockmore.html
- xscreensaver http://www.jwz.org/xscreensaver/
- xtrlock ftp://ftp.debian.org/debian/dists/stable/main/source/x11/

View file

@ -9,7 +9,7 @@ alock_sources = [ 'alock.c', 'alock_utils.c' ]
auth_sources = [ 'auth_none.c' ]
bg_sources = [ 'bg_none.c', 'bg_blank.c' ]
cursor_sources = [ 'cursor_none.c', 'cursor_theme.c', 'cursor_font.c' ]
cursor_sources = [ 'cursor_none.c', 'cursor_theme.c', 'cursor_glyph.c' ]
Import('alock_env')

View file

@ -49,7 +49,7 @@ static struct aBackground* alock_backgrounds[] = {
&alock_bg_none,
&alock_bg_blank,
#ifdef HAVE_IMLIB2
&alock_bg_imlib2,
&alock_bg_image,
#endif /* HAVE_IMLIB2 */
#ifdef HAVE_XRENDER
&alock_bg_shade,
@ -60,7 +60,7 @@ static struct aBackground* alock_backgrounds[] = {
static struct aCursor* alock_cursors[] = {
&alock_cursor_none,
&alock_cursor_theme,
&alock_cursor_font,
&alock_cursor_glyph,
#ifdef HAVE_XCURSOR
&alock_cursor_xcursor,
#endif /* HAVE_XCURSOR */

View file

@ -67,6 +67,7 @@ struct aOpts {
/*------------------------------------------------------------------*\
\*------------------------------------------------------------------*/
void alock_string2lower(char* string);
int alock_alloc_color(const struct aXInfo* xinfo, const char* color_name,
const char* fallback_name, XColor* result);
int alock_check_xrender(const struct aXInfo* xinfo);
@ -84,7 +85,7 @@ int alock_shade_pixmap(const struct aXInfo* xinfo,
extern struct aBackground alock_bg_none;
extern struct aBackground alock_bg_blank;
#ifdef HAVE_IMLIB2
extern struct aBackground alock_bg_imlib2;
extern struct aBackground alock_bg_image;
#endif /* HAVE_IMLIB2 */
#ifdef HAVE_XRENDER
extern struct aBackground alock_bg_shade;
@ -106,7 +107,7 @@ extern struct aAuth alock_auth_pam;
\*------------------------------------------------------------------*/
extern struct aCursor alock_cursor_none;
extern struct aCursor alock_cursor_theme;
extern struct aCursor alock_cursor_font;
extern struct aCursor alock_cursor_glyph;
#ifdef HAVE_XCURSOR
extern struct aCursor alock_cursor_xcursor;
#endif /* HAVE_XCURSOR */

View file

@ -23,8 +23,18 @@
# include <X11/extensions/Xrender.h>
#endif /* HAVE_XRENDER */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "alock.h"
/*------------------------------------------------------------------*\
\*------------------------------------------------------------------*/
void alock_string2lower(char* string) {
static unsigned int i;
for(i = strlen(string) - 1; i; --i)
tolower(string[i]);
}
/* ---------------------------------------------------------------- *\
\* ---------------------------------------------------------------- */
int alock_alloc_color(const struct aXInfo* xinfo, const char* color_name,
@ -91,6 +101,7 @@ int alock_shade_pixmap(const struct aXInfo* xinfo,
{ /* fill the alpha-picture */
Pixmap alpha_pm = None;
XRenderColor alpha_color;
XRenderPictureAttributes alpha_attr;

View file

@ -23,7 +23,7 @@
about :
provide -auth md5:hash
provide -auth md5:hash=<hash>,file=<filename>
\* ---------------------------------------------------------------- */
@ -34,6 +34,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef STAND_ALONE
# include <X11/Xlib.h>
# include "alock.h"
@ -286,29 +287,81 @@ static void md5_transform(u_int32_t state[4], const u_int8_t block[MD5_BLOCK_LEN
#ifndef STAND_ALONE
static const char* userhash = NULL;
static char* userhash = NULL;
static int alock_auth_md5_init(const char* args) {
if (args) {
char* check = strstr(args, "md5:");
if (!check || check != args) {
fprintf(stderr, "alock: error, missing arguments for [md5].\n");
return 0;
}
if (strlen(&args[4]) != MD5_DIGEST_STRING_LENGTH - 1) {
fprintf(stderr, "alock: error, invalid md5-hash.\n");
return 0;
}
userhash = &args[4];
return 1;
if (!args) {
fprintf(stderr, "alock: error, missing arguments for [md5].\n");
return 0;
}
return 0;
if (strstr(args, "md5:") == args && strlen(&args[4]) > 0) {
char* arguments = strdup(&args[4]);
char* tmp;
char* arg = NULL;
for (tmp = arguments; tmp; ) {
arg = strsep(&tmp, ",");
if (arg && !userhash) {
if (strstr(arg, "hash=") == arg && strlen(arg) > 5) {
if (strlen(&arg[5]) == MD5_DIGEST_STRING_LENGTH - 1) {
if (!userhash)
userhash = strdup(&arg[5]);
} else {
printf("alock: error, missing or incorrect hash for [md5].\n");
free(arguments);
return 0;
}
} else if (strstr(arg, "file=") == arg && strlen(arg) > 6) {
char* tmp_hash = NULL;
FILE* hashfile = fopen(&arg[5], "r");
if (hashfile) {
int c;
unsigned int i = 0;
tmp_hash = (char*)malloc(MD5_DIGEST_STRING_LENGTH);
memset(tmp_hash, 0, MD5_DIGEST_STRING_LENGTH);
for(i = 0, c = fgetc(hashfile);
i < MD5_DIGEST_STRING_LENGTH - 1 && c != EOF; i++, c = fgetc(hashfile)) {
tmp_hash[i] = tolower(c);
}
fclose(hashfile);
} else {
printf("alock: error, couldnt read [%s] for [md5].\n",
&arg[5]);
free(arguments);
return 0;
}
if (!tmp_hash || strlen(tmp_hash) != MD5_DIGEST_STRING_LENGTH - 1) {
printf("alock: error, given file [%s] doesnt contain a valid hash for [md5].\n",
&arg[5]);
free(arguments);
return 0;
}
userhash = tmp_hash;
}
}
}
free(arguments);
} else {
fprintf(stderr, "alock: error, missing arguments for [md5].\n");
return 0;
}
if (!userhash) {
printf("alock: error, missing hash for [md5].\n");
return 0;
}
alock_string2lower(userhash);
return 1;
}
static int alock_auth_md5_deinit() {
if (userhash)
free(userhash);
return 1;
}

View file

@ -17,7 +17,7 @@
about :
provide -auth sha1:hash
provide -auth sha1:hash=<hash>,file=<filename>
\* ---------------------------------------------------------------- */
@ -30,6 +30,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef STAND_ALONE
# include <X11/Xlib.h>
# include "alock.h"
@ -222,29 +223,81 @@ static void sha1_final(u_int8_t digest[SHA1_DIGEST_LENGTH], sha1Context *context
\* ---------------------------------------------------------------- */
#ifndef STAND_ALONE
static const char* userhash = NULL;
static char* userhash = NULL;
static int alock_auth_sha1_init(const char* args) {
if (args) {
char* check = strstr(args, "sha1:");
if (!check || check != args) {
fprintf(stderr, "alock: error, missing arguments for [sha1].\n");
return 0;
}
if (strlen(&args[5]) != SHA1_DIGEST_STRING_LENGTH - 1) {
fprintf(stderr, "alock: error, invalid sha1-hash.\n");
return 0;
}
userhash = &args[5];
return 1;
if (!args) {
fprintf(stderr, "alock: error, missing arguments for [sha1].\n");
return 0;
}
return 0;
if (strstr(args, "sha1:") == args && strlen(&args[5]) > 0) {
char* arguments = strdup(&args[5]);
char* tmp;
char* arg = NULL;
for (tmp = arguments; tmp; ) {
arg = strsep(&tmp, ",");
if (arg && !userhash) {
if (strstr(arg, "hash=") == arg && strlen(arg) > 5) {
if (strlen(&arg[5]) == SHA1_DIGEST_STRING_LENGTH - 1) {
if (!userhash)
userhash = strdup(&arg[5]);
} else {
printf("alock: error, missing or incorrect hash for [sha1].\n");
free(arguments);
return 0;
}
} else if (strstr(arg, "file=") == arg && strlen(arg) > 6) {
char* tmp_hash = NULL;
FILE* hashfile = fopen(&arg[5], "r");
if (hashfile) {
int c;
unsigned int i = 0;
tmp_hash = (char*)malloc(SHA1_DIGEST_STRING_LENGTH);
memset(tmp_hash, 0, SHA1_DIGEST_STRING_LENGTH);
for(i = 0, c = fgetc(hashfile);
i < SHA1_DIGEST_STRING_LENGTH - 1 && c != EOF; i++, c = fgetc(hashfile)) {
tmp_hash[i] = tolower(c);
}
fclose(hashfile);
} else {
printf("alock: error, couldnt read [%s] for [md5].\n",
&arg[5]);
free(arguments);
return 0;
}
if (!tmp_hash || strlen(tmp_hash) != SHA1_DIGEST_STRING_LENGTH - 1) {
printf("alock: error, given file [%s] doesnt contain a valid hash for [sha1].\n",
&arg[5]);
free(arguments);
return 0;
}
userhash = tmp_hash;
}
}
}
free(arguments);
} else {
fprintf(stderr, "alock: error, missing arguments for [sha1].\n");
return 0;
}
if (!userhash) {
printf("alock: error, missing hash for [sha1].\n");
return 0;
}
alock_string2lower(userhash);
return 1;
}
static int alock_auth_sha1_deinit() {
if (userhash)
free(userhash);
return 1;
}

View file

@ -41,7 +41,7 @@ static Window window = 0;
static Pixmap pixmap = 0;
static XColor color;
static int alock_bg_imlib2_init(const char* args, struct aXInfo* xinfo) {
static int alock_bg_image_init(const char* args, struct aXInfo* xinfo) {
XWindowAttributes xgwa;
XSetWindowAttributes xswa;
@ -77,13 +77,15 @@ static int alock_bg_imlib2_init(const char* args, struct aXInfo* xinfo) {
} else {
printf("alock: error, shade not in range [1, 99] for [image].\n");
free(color_name);
if (filename)
free(filename);
free(arguments);
return 0;
}
} else {
} else if (strstr(arg, "file=") == arg && strlen(arg) > 6) {
if (!filename)
filename = strdup(arg);
filename = strdup(&arg[5]);
}
}
}
@ -235,7 +237,7 @@ static int alock_bg_imlib2_init(const char* args, struct aXInfo* xinfo) {
}
static int alock_bg_imlib2_deinit(struct aXInfo* xinfo) {
static int alock_bg_image_deinit(struct aXInfo* xinfo) {
if (!xinfo || !window)
return 0;
XDestroyWindow(xinfo->display, window);
@ -243,10 +245,10 @@ static int alock_bg_imlib2_deinit(struct aXInfo* xinfo) {
return 1;
}
struct aBackground alock_bg_imlib2 = {
struct aBackground alock_bg_image = {
"image",
alock_bg_imlib2_init,
alock_bg_imlib2_deinit
alock_bg_image_init,
alock_bg_image_deinit
};
/* ---------------------------------------------------------------- *\

View file

@ -97,7 +97,6 @@ static int alock_bg_shade_init(const char* args, struct aXInfo* xinfo) {
Window root = xinfo->root;
int scrnr = DefaultScreen(dpy);
int depth = DefaultDepth(dpy, scrnr);
Visual* vis = DefaultVisual(dpy, scrnr);
GC gc = DefaultGC(dpy, scrnr);
{ /* grab whats on the screen */

View file

@ -1,6 +1,6 @@
/* ---------------------------------------------------------------- *\
file : cursor_font.c
file : cursor_glyph.c
author : m. gumz <akira at fluxbox dot org>
copyr : copyright (c) 2005 by m. gumz
@ -125,9 +125,8 @@ static Cursor cursor = 0;
static XColor color_fg;
static XColor color_bg;
static int alock_cursor_font_init(const char* args, struct aXInfo* xinfo) {
static int alock_cursor_glyph_init(const char* args, struct aXInfo* xinfo) {
XColor tmp_color;
char* color_bg_name = strdup("steelblue3");
char* color_fg_name = strdup("grey25");
unsigned int shape = 0; /* XC_X_cursor */
@ -135,42 +134,38 @@ static int alock_cursor_font_init(const char* args, struct aXInfo* xinfo) {
if (!xinfo || !args)
return 0;
if (strstr(args, "font:") == args && strlen(&args[5]) > 0) {
char* arguments = strdup(&args[5]);
if (strstr(args, "glyph:") == args && strlen(&args[6]) > 0) {
char* arguments = strdup(&args[6]);
char* tmp;
char* arg = NULL;
for (tmp = arguments; tmp; ) {
arg = strsep(&tmp, ",");
if (arg) {
const struct CursorFontName* cursor_font_name;
const struct CursorFontName* cursor_glyph_name;
if (!strcmp(arg, "list")) {
for (cursor_font_name = cursor_names; cursor_font_name->name; ++cursor_font_name) {
printf("%s\n", cursor_font_name->name);
for (cursor_glyph_name = cursor_names; cursor_glyph_name->name; ++cursor_glyph_name) {
printf("%s\n", cursor_glyph_name->name);
}
free(color_fg_name);
free(color_bg_name);
free(arguments);
exit(0);
}
if (strstr(arg, "fg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) {
} else if (strstr(arg, "fg=") == arg && strlen(arg) > 4) {
free(color_fg_name);
color_fg_name = strdup(&arg[3]);
}
else if (strstr(arg, "bg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) {
} else if (strstr(arg, "bg=") == arg && strlen(arg) > 4) {
free(color_bg_name);
color_bg_name = strdup(&arg[3]);
}
else {
/* TODO: accept <int> as well -> strtol */
for (cursor_font_name = cursor_names; cursor_font_name->name; ++cursor_font_name) {
if(!strcmp(cursor_font_name->name, arg)) {
shape = cursor_font_name->shape;
} else if (strstr(arg, "name=") == arg && strlen(arg) > 6) {
for (cursor_glyph_name = cursor_names; cursor_glyph_name->name; ++cursor_glyph_name) {
if(!strcmp(cursor_glyph_name->name, &arg[5])) {
shape = cursor_glyph_name->shape;
break;
}
}
if (!cursor_font_name->name) {
printf("alock: error, couldnt find [%s]\n", arg);
if (!cursor_glyph_name->name) {
printf("alock: error, couldnt find [%s]\n", &arg[5]);
free(color_bg_name);
free(color_fg_name);
free(arguments);
@ -182,10 +177,8 @@ static int alock_cursor_font_init(const char* args, struct aXInfo* xinfo) {
free(arguments);
}
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_bg_name, &tmp_color, &color_bg)) == 0)
XAllocNamedColor(xinfo->display, xinfo->colormap, "black", &tmp_color, &color_bg);
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_fg_name, &tmp_color, &color_fg)) == 0)
XAllocNamedColor(xinfo->display, xinfo->colormap, "white", &tmp_color, &color_fg);
alock_alloc_color(xinfo, color_bg_name, "black", &color_bg);
alock_alloc_color(xinfo, color_fg_name, "white", &color_fg);
free(color_fg_name);
free(color_bg_name);
@ -202,7 +195,7 @@ static int alock_cursor_font_init(const char* args, struct aXInfo* xinfo) {
return 1;
}
static int alock_cursor_font_deinit(struct aXInfo* xinfo) {
static int alock_cursor_glyph_deinit(struct aXInfo* xinfo) {
if (!xinfo || !cursor)
return 0;
@ -212,10 +205,10 @@ static int alock_cursor_font_deinit(struct aXInfo* xinfo) {
}
struct aCursor alock_cursor_font = {
"font",
alock_cursor_font_init,
alock_cursor_font_deinit
struct aCursor alock_cursor_glyph = {
"glyph",
alock_cursor_glyph_init,
alock_cursor_glyph_deinit
};

View file

@ -78,7 +78,6 @@ static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) {
char* color_bg_name = strdup("steelblue3");
char* color_fg_name = strdup("grey25");
XColor tmp_color;
Pixmap pixmap_cursor;
Pixmap pixmap_cursor_mask;
const struct ThemeCursor* theme = cursors;
@ -103,18 +102,15 @@ static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) {
free(color_bg_name);
free(arguments);
exit(0);
}
if (strstr(arg, "fg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) {
} else if (strstr(arg, "fg=") == arg && strlen(arg) > 4) {
free(color_fg_name);
color_fg_name = strdup(&arg[3]);
}
else if (strstr(arg, "bg=") == arg && strlen(arg) > 3 && strlen(&arg[3])) {
} else if (strstr(arg, "bg=") == arg && strlen(arg) > 4) {
free(color_bg_name);
color_bg_name = strdup(&arg[3]);
}
else {
} else if (strstr(arg, "name=") == arg && strlen(arg) > 6) {
for (cursor_theme_name = cursors; cursor_theme_name->name; ++cursor_theme_name) {
if(!strcmp(cursor_theme_name->name, arg)) {
if(!strcmp(cursor_theme_name->name, &arg[5])) {
theme = cursor_theme_name;
break;
}
@ -132,10 +128,8 @@ static int alock_cursor_theme_init(const char* args, struct aXInfo* xinfo) {
free(arguments);
}
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_bg_name, &tmp_color, &color_bg)) == 0)
XAllocNamedColor(xinfo->display, xinfo->colormap, "black", &tmp_color, &color_bg);
if((XAllocNamedColor(xinfo->display, xinfo->colormap, color_fg_name, &tmp_color, &color_fg)) == 0)
XAllocNamedColor(xinfo->display, xinfo->colormap, "white", &tmp_color, &color_fg);
alock_alloc_color(xinfo, color_fg_name, "white", &color_fg);
alock_alloc_color(xinfo, color_bg_name, "blank", &color_bg);
free(color_fg_name);
free(color_bg_name);