Adding SUDO_ASKPASS support to thinglaunch. - thinglaunch - A simple command and password promtper for X11.
 (HTM) git clone git://bitreich.org/thinglaunch
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) LICENSE
       ---
 (DIR) commit 86ab2b59e05a3f9c234d5564c9e41f2d46d5953d
 (DIR) parent c13c797ba4f26cdbff560020a815fea564d8c60b
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sun, 10 Apr 2011 16:53:38 +0200
       
       Adding SUDO_ASKPASS support to thinglaunch.
       
       Diffstat:
         M Makefile                            |       7 +++++--
         M README.md                           |      17 +++++++++++++++++
         M thinglaunch.c                       |      10 ++++++++++
       
       3 files changed, 32 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/Makefile b/Makefile
       @@ -29,10 +29,12 @@ ${NAME}: ${OBJ}
                @echo CC -o $@
                @${CC} -o $@ ${OBJ} ${LDFLAGS}
                @ln -s ${NAME} thingaskpass 2>/dev/null; true
       +        @ln -s ${NAME} thingsudoaskpass 2>/dev/null; true
        
        clean:
                @echo cleaning
       -        @rm -f ${NAME} *.o thingaskpass ${OBJ} ${NAME}-${VERSION}.tar.gz
       +        @rm -f ${NAME} *.o thingaskpass thingsudoaskpass ${OBJ} \
       +                ${NAME}-${VERSION}.tar.gz
        
        dist: clean
                @echo creating dist tarball
       @@ -51,12 +53,13 @@ etc:
        install: all
                @echo installing executable file to ${DESTDIR}${PREFIX}/bin
                @mkdir -p ${DESTDIR}${PREFIX}/bin
       -        @cp -f ${NAME} thingaskpass ${DESTDIR}${PREFIX}/bin
       +        @cp -f ${NAME} thingaskpass thingsudoaskpass ${DESTDIR}${PREFIX}/bin
                @chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}
        
        uninstall:
                @echo removing executable file from ${DESTDIR}${PREFIX}/bin
                @rm -f ${DESTDIR}${PREFIX}/bin/${NAME}
                @rm -f ${DESTDIR}${PREFIX}/bin/thingaskpass
       +        @rm -f ${DESTDIR}${PREFIX}/bin/thingsudoaskpass
        
        .PHONY: all options clean dist install uninstall
 (DIR) diff --git a/README.md b/README.md
       @@ -32,5 +32,22 @@ be used by ssh-agent to gather the password for private keys.
                % ln -s thinglaunch thingaskpass
                % ./thingaskpass
        
       +        # This symlink predefined -s, -o and takes the prompt as first
       +        # argument.
       +        % ln -s thinglaunch thingsudoaskpass
       +        % ./thingsudoaskpass
       +
       +## SSH_ASKPASS
       +
       +If you set SSH_ASKPASS to the PATH to thingaskpass (usually /usr/bin/
       +thingaskpass), then ssh-agent will use this command for asking for pass-
       +words.
       +
       +## SUDO_ASKPASS
       +
       +This is the same as SSH_ASKPASS, but here you need to set SUDO_ASKPASS
       +to the PATH to thingsudoaskpass (usually /usr/bin/thingsudoaskpass).
       +
       +
        Have fun!
        
 (DIR) diff --git a/thinglaunch.c b/thinglaunch.c
       @@ -72,6 +72,16 @@ main(int argc, char *argv[])
                        tostdout = 1;
                        prompt = "secret> ";
                }
       +        if (strstr(argv[0], "thingsudoaskpass")) {
       +                issecret = 1;
       +                tostdout = 1;
       +                if (argc > 1)
       +                        prompt = argv[1];
       +                else
       +                        prompt = "secret sudo> ";
       +                argc = 0;
       +        }
       +
                if (argc > 1) {
                        for (i = 1; argv[i]; i++) {
                                if (argv[i][0] == '-') {