]> www.average.org Git - pam_pcsc_cr.git/commitdiff
eprint don't need \n in the format
authorEugene Crosser <crosser@average.org>
Sun, 10 Nov 2013 20:30:21 +0000 (00:30 +0400)
committerEugene Crosser <crosser@average.org>
Sun, 10 Nov 2013 20:30:21 +0000 (00:30 +0400)
authfile.c
pam_cr_setup.c

index 1e0826d4d8396505f7da71a1f8e3c0a8dad99dd1..8b077df0a0c74e2bb800b6f6883fba18acdaa7da 100644 (file)
@@ -42,7 +42,7 @@ int update_authfile(const char *fn, const char *tokenid, const char *id,
                        oldnonce = strtok(NULL, ":\r\n");
                        hauthobj = strtok(NULL, ":\r\n");
                } else {
                        oldnonce = strtok(NULL, ":\r\n");
                        hauthobj = strtok(NULL, ":\r\n");
                } else {
-                       eprint("error reading from %s: %s\n",
+                       eprint("error reading from %s: %s",
                                fn, strerror(errno));
                }
                fclose(fp);
                                fn, strerror(errno));
                }
                fclose(fp);
@@ -52,10 +52,10 @@ int update_authfile(const char *fn, const char *tokenid, const char *id,
 
                hlen = strlen(hauthobj);
                if (hlen % 32 != 0) {
 
                hlen = strlen(hauthobj);
                if (hlen % 32 != 0) {
-                       eprint("error: auth string has wrong length\n");
+                       eprint("error: auth string has wrong length");
                } else if (hlen !=
                                strspn(hauthobj, "0123456789abcdefABCDEF")) {
                } else if (hlen !=
                                strspn(hauthobj, "0123456789abcdefABCDEF")) {
-                       eprint("error: auth string not hexadecimal\n");
+                       eprint("error: auth string not hexadecimal");
                } else {
                        oldauthsize = hlen/2;
                        oldauthobj = alloca(oldauthsize);
                } else {
                        oldauthsize = hlen/2;
                        oldauthobj = alloca(oldauthsize);
@@ -71,18 +71,18 @@ int update_authfile(const char *fn, const char *tokenid, const char *id,
 
                rc = make_challenge(id, password, nonce, chal, &csize);
                if (rc) {
 
                rc = make_challenge(id, password, nonce, chal, &csize);
                if (rc) {
-                       eprint("cannot make challenge\n");
+                       eprint("cannot make challenge");
                        return -1;
                }
                rc = pcsc_cr(chal, csize, key, &keysize);
                if (rc) {
                        return -1;
                }
                rc = pcsc_cr(chal, csize, key, &keysize);
                if (rc) {
-                       eprint("error querying token: %s\n", pcsc_errstr(rc));
+                       eprint("error querying token: %s", pcsc_errstr(rc));
                        return -1;
                }
                rc = parse_authobj(key, keysize, oldauthobj, oldauthsize,
                        mysecret, &mysecsize, myload, &myloadsize);
                if (rc) {
                        return -1;
                }
                rc = parse_authobj(key, keysize, oldauthobj, oldauthsize,
                        mysecret, &mysecsize, myload, &myloadsize);
                if (rc) {
-                       eprint("cannot parse old authobj: %d\n", rc);
+                       eprint("cannot parse old authobj: %d", rc);
                        return -1;
                }
        }
                        return -1;
                }
        }
@@ -90,29 +90,29 @@ int update_authfile(const char *fn, const char *tokenid, const char *id,
        rc = make_authobj(id, password, nonce, mysecret, mysecsize,
                        payload, paysize, authobj, &authsize);
        if (rc) {
        rc = make_authobj(id, password, nonce, mysecret, mysecsize,
                        payload, paysize, authobj, &authsize);
        if (rc) {
-               eprint("make_authobj error %d\n", rc);
+               eprint("make_authobj error %d", rc);
                return -1;
        }
        fp = fopen(fn, "w");
        if (!fp) {
                return -1;
        }
        fp = fopen(fn, "w");
        if (!fp) {
-               eprint("cannot open \"%s\": %s\n",
+               eprint("cannot open \"%s\": %s",
                        fn, strerror(errno));
                return -1;
        }
        if (fprintf(fp, "%s:%s:%s:", tokenid, id, nonce) < 0) {
                        fn, strerror(errno));
                return -1;
        }
        if (fprintf(fp, "%s:%s:%s:", tokenid, id, nonce) < 0) {
-               eprint("cannot write to \"%s\": %s\n",
+               eprint("cannot write to \"%s\": %s",
                        fn, strerror(errno));
                return -1;
        }
        for (i = 0; i < authsize; i++)
            if (fprintf(fp, "%02x", authobj[i]) < 0) {
                        fn, strerror(errno));
                return -1;
        }
        for (i = 0; i < authsize; i++)
            if (fprintf(fp, "%02x", authobj[i]) < 0) {
-               eprint("cannot write to \"%s\": %s\n",
+               eprint("cannot write to \"%s\": %s",
                        fn, strerror(errno));
                return -1;
        }
        fprintf(fp, "\n");
        if (fclose(fp) < 0) {
                        fn, strerror(errno));
                return -1;
        }
        fprintf(fp, "\n");
        if (fclose(fp) < 0) {
-               eprint("cannot close \"%s\": %s\n",
+               eprint("cannot close \"%s\": %s",
                        fn, strerror(errno));
                return -1;
        }
                        fn, strerror(errno));
                return -1;
        }
index 11a8e2ab9bfef0c33f5bf403d73bb8b6758c9e6f..e7e6006a23d6ccadfcb8a0a6db51f13e7ecac28f 100644 (file)
 int eprint(const char *format, ...)
 {
        va_list ap;
 int eprint(const char *format, ...)
 {
        va_list ap;
+       char *nfmt;
 
 
+       nfmt = alloca(strlen(format)+2);
+       strcpy(nfmt, format);
+       strcat(nfmt, "\n");
        va_start(ap, format);
        va_start(ap, format);
-       return vfprintf(stderr, format, ap);
+       return vfprintf(stderr, nfmt, ap);
        va_end(ap);
 }
 
        va_end(ap);
 }
 
@@ -30,7 +34,7 @@ static void usage(const char const *cmd)
                "    -s token-serial   - public I.D. of the token\n"
                "    -n nonce          - initial nonce\n"
                "    -l payload        - keyring unlock password\n"
                "    -s token-serial   - public I.D. of the token\n"
                "    -n nonce          - initial nonce\n"
                "    -l payload        - keyring unlock password\n"
-               "    -p password       - login password\n"
+               "    -p password       - login password"
                , cmd);
 }
 
                , cmd);
 }
 
@@ -57,7 +61,7 @@ int main(int argc, char *argv[])
                exit(EXIT_SUCCESS);
        case 'o':
                if (pcsc_option(optarg)) {
                exit(EXIT_SUCCESS);
        case 'o':
                if (pcsc_option(optarg)) {
-                       eprint("Option \"%s\" bad\n", optarg);
+                       eprint("Option \"%s\" bad", optarg);
                        exit(EXIT_FAILURE);
                }
                break;
                        exit(EXIT_FAILURE);
                }
                break;
@@ -68,7 +72,7 @@ int main(int argc, char *argv[])
                if (!secfn) {
                        hsecret = optarg;
                } else {
                if (!secfn) {
                        hsecret = optarg;
                } else {
-                       eprint("-a and -A are mutually exclusive\n");
+                       eprint("-a and -A are mutually exclusive");
                        exit(EXIT_FAILURE);
                }
                break;
                        exit(EXIT_FAILURE);
                }
                break;
@@ -76,7 +80,7 @@ int main(int argc, char *argv[])
                if (!hsecret) {
                        secfn = optarg;
                } else {
                if (!hsecret) {
                        secfn = optarg;
                } else {
-                       eprint("-A and -a are mutually exclusive\n");
+                       eprint("-A and -a are mutually exclusive");
                        exit(EXIT_FAILURE);
                }
                break;
                        exit(EXIT_FAILURE);
                }
                break;
@@ -111,12 +115,12 @@ int main(int argc, char *argv[])
                if (!strcmp(secfn, "-")) sfp = stdin;
                else sfp = fopen(secfn, "r");
                if (!sfp) {
                if (!strcmp(secfn, "-")) sfp = stdin;
                else sfp = fopen(secfn, "r");
                if (!sfp) {
-                       eprint("cannot open \"%s\": %s\n",
+                       eprint("cannot open \"%s\": %s",
                                secfn, strerror(errno));
                        exit(EXIT_FAILURE);
                }
                if (!fgets(secbuf, sizeof(secbuf), sfp)) {
                                secfn, strerror(errno));
                        exit(EXIT_FAILURE);
                }
                if (!fgets(secbuf, sizeof(secbuf), sfp)) {
-                       eprint("cannot read \"%s\": %s\n",
+                       eprint("cannot read \"%s\": %s",
                                secfn, strerror(errno));
                        exit(EXIT_FAILURE);
                }
                                secfn, strerror(errno));
                        exit(EXIT_FAILURE);
                }
@@ -127,7 +131,7 @@ int main(int argc, char *argv[])
                hsecret = secbuf;
        }
        if (!id) {
                hsecret = secbuf;
        }
        if (!id) {
-               eprint("cannot determine userid\n");
+               eprint("cannot determine userid");
                exit(EXIT_FAILURE);
        }
        if (hsecret) {
                exit(EXIT_FAILURE);
        }
        if (hsecret) {