From 7d639dea61a7c965b9a8825ad89a4a489bd1d997 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 13 Jan 2008 18:12:20 +0000 Subject: [PATCH] Add config file command "chpasswd" which will prompr user to change his password, if logged in. Also, remove dgl-wall from Makefile, because it doesn't work anymore. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@417 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- Makefile.in | 10 +++------- config.l | 1 + config.y | 17 ++++++++++++++++- dgamelaunch.h | 3 ++- dgl-common.c | 3 +++ examples/dgamelaunch.conf | 1 + 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4928f62..fc904c7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,21 +22,17 @@ EDITOR = @EDITOR@ STATIC_SRCS = $(EDITOR) dgl-common.c ttyrec.c dgamelaunch.c io.c ttyplay.c mygetnstr.c stripgfx.c strlcpy.c strlcat.c @SETPROCTITLE_C@ DYN_SRCS = y.tab.c lex.yy.c EXTRA_SRCS = nethackstub.c -DEP_SRCS := $(STATIC_SRCS) $(EXTRA_SRCS) dgl-wall.c +DEP_SRCS := $(STATIC_SRCS) $(EXTRA_SRCS) SRCS := $(STATIC_SRCS) $(DYN_SRCS) OBJS = $(SRCS:.c=.o) -WALL_OBJS = y.tab.o lex.yy.o dgl-common.o dgl-wall.o strlcat.o strlcpy.o -all: .depend $(NAME) dgl-wall +all: .depend $(NAME) $(NAME): $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -dgl-wall: $(WALL_OBJS) - $(CC) $(CFLAGS) -o $@ $(WALL_OBJS) $(LIBS) - clean: - rm -f $(NAME) nethackstub dgl-wall + rm -f $(NAME) nethackstub rm -f *.o *~ y.tab.* lex.yy.c .depend .depend.bak distclean: clean diff --git a/config.l b/config.l index 82ed757..9f53925 100644 --- a/config.l +++ b/config.l @@ -92,6 +92,7 @@ ifnxcp { yylval.i = DGLCMD_IF_NX_CP; return TYPE_DGLCMD2; } unlink { yylval.i = DGLCMD_UNLINK; return TYPE_DGLCMD1; } setenv { yylval.i = DGLCMD_SETENV; return TYPE_DGLCMD2; } exec { yylval.i = DGLCMD_EXEC; return TYPE_DGLCMD2; } +chpasswd { yylval.i = DGLCMD_CHPASSWD; return TYPE_DGLCMD0; } DEFINE { return TYPE_DEFINE_GAME; } diff --git a/config.y b/config.y index 1a35661..b18b613 100644 --- a/config.y +++ b/config.y @@ -43,7 +43,7 @@ static const char* lookup_token (int t); %token TYPE_VALUE %token TYPE_NUMBER TYPE_CMDQUEUENAME %type KeyType -%token TYPE_DGLCMD1 TYPE_DGLCMD2 +%token TYPE_DGLCMD0 TYPE_DGLCMD1 TYPE_DGLCMD2 %token TYPE_DEFINE_GAME %token TYPE_BOOL @@ -368,6 +368,21 @@ dglcmd : TYPE_DGLCMD1 TYPE_VALUE } } + | TYPE_DGLCMD0 + { + struct dg_cmdpart *tmp = malloc(sizeof(struct dg_cmdpart)); + if (tmp) { + struct dg_cmdpart *foo = curr_cmdqueue; + if (foo) { + while (foo->next) foo = foo->next; + foo->next = tmp; + } else curr_cmdqueue = tmp; + tmp->next = NULL; + tmp->param1 = NULL; + tmp->param2 = NULL; + tmp->cmd = $1; + } + } | TYPE_DGLCMD2 TYPE_VALUE TYPE_VALUE { struct dg_cmdpart *tmp = malloc(sizeof(struct dg_cmdpart)); diff --git a/dgamelaunch.h b/dgamelaunch.h index 39a05d5..a9a2fe5 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -103,7 +103,8 @@ typedef enum DGLCMD_CP, /* cp foo bar */ DGLCMD_UNLINK, /* unlink foo */ DGLCMD_EXEC, /* exec foo bar */ - DGLCMD_SETENV /* setenv foo bar */ + DGLCMD_SETENV, /* setenv foo bar */ + DGLCMD_CHPASSWD /* chpasswd */ } dglcmd_actions; typedef enum diff --git a/dgl-common.c b/dgl-common.c index a9ec2d6..603713a 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -197,6 +197,9 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me) case DGLCMD_SETENV: if (p1 && p2) mysetenv(p1, p2, 1); break; + case DGLCMD_CHPASSWD: + if (loggedin) changepw(1); + break; } free(p1); free(p2); diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index dd2c092..8693f7d 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -75,6 +75,7 @@ lockfile = "/dgl-lock" # unlink "foo" = deletes file "foo" # setenv "foo "bar" = sets environment variable "foo" to "bar" # exec "foo" "bar" = execute "foo" with "bar" as it's param +# chpasswd = do the change password prompting, if logged in # # The commands will be done inside the chroot and with the uid and gid # defined above.