tAllow disabling signature checking - repo - list/download/sync packs with remote repositories
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit ebfc5f6438f11297572ae07d75bd0fa57f1261df
 (DIR) parent ec303804d9ff0363169e863506238d7096f45bfb
 (HTM) Author: z3bra <contactatz3bradotorg>
       Date:   Thu,  4 May 2017 13:44:10 +0200
       
       Allow disabling signature checking
       
       A compile time flag allow disabling calls too sick(1) completely.
       
       Diffstat:
         M config.mk                           |       2 +-
         M repo.c                              |      32 ++++++++++++++++++++++---------
       
       2 files changed, 24 insertions(+), 10 deletions(-)
       ---
 (DIR) diff --git a/config.mk b/config.mk
       t@@ -7,7 +7,7 @@ YACC = yacc
        PREFIX = /usr/local
        MANDIR = ${PREFIX}/man
        
       -CPPFLAGS = -DVERSION=\"${VERSION}\"
       +CPPFLAGS = -DVERSION=\"${VERSION}\" -DCHECKSIG
        CFLAGS = ${CPPFLAGS} -Wall -Wextra -pedantic -g
        LDFLAGS =
        LIBS = -lcurl -lssl -lcrypto -ldl -lz -lpthread 
 (DIR) diff --git a/repo.c b/repo.c
       t@@ -23,7 +23,9 @@ int cachepack(char *, char *, struct packs *);
        int verbose = 0;
        int fflag, lflag, sflag;
        
       +#ifdef CHECKSIG
        char *sickexec[] = { "sick", "-a", NULL };
       +#endif
        
        void
        usage(char *name)
       t@@ -145,11 +147,13 @@ download(char *url, FILE *fd)
        int
        cachepack(char *name, char *localrepo, struct packs *plist)
        {
       -        FILE *pip;
       -        int fd[2], fil, status;
       +        FILE *f;
                char fn[PATH_MAX];;
                struct pack *p = NULL;
                struct stat sb;
       +#ifdef CHECKSIG
       +        int fd[2], out, status;
       +#endif
        
                TAILQ_FOREACH(p, plist, entries) {
                        if (!strncmp(p->name, name, PATH_MAX)) {
       t@@ -159,6 +163,7 @@ cachepack(char *name, char *localrepo, struct packs *plist)
                                        continue;
                                }
        
       +#ifdef CHECKSIG
                                pipe(fd);
                                if (!fork()) {
                                        close(0);
       t@@ -166,31 +171,40 @@ cachepack(char *name, char *localrepo, struct packs *plist)
                                        close(fd[1]);
                                        dup2(fd[0], 0);
        
       -                                if ((fil = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
       +                                if ((out = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
                                                perror(fn);
                                                return -1;
                                        }
       -                                dup2(fil, 1);
       +                                dup2(out, 1);
                                        execvp(sickexec[0], sickexec);
                                        perror(sickexec[0]);
                                }
        
                                close(fd[0]);
       -                        pip = fdopen(fd[1], "a");
       -                        if (!pip) {
       +                        f = fdopen(fd[1], "a");
       +                        if (!f) {
                                        perror("pipe");
                                        exit(1);
                                }
       -                        download(p->url, pip);
       -                        fflush(pip);
       -                        fclose(pip);
       +#else
       +                        f = fopen(fn, "a");
       +                        if (!f) {
       +                                perror(fn);
       +                                exit(1);
       +                        }
       +#endif
       +                        download(p->url, f);
       +                        fflush(f);
       +                        fclose(f);
        
       +#ifdef CHECKSIG
                                wait(&status);
                                if (status) {
                                        fprintf(stderr, "%s: Pack verification failed\n", basename(fn));
                                        unlink(fn);
                                        continue;
                                }
       +#endif
                                puts(fn);
                                break;
                        }