wip single-function authobj
[pam_pcsc_cr.git] / pam_cr_setup.c
index 11a8e2ab9bfef0c33f5bf403d73bb8b6758c9e6f..e0fb52a61d992cffa912cde3de482d39d7431902 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);
 }
 
@@ -44,8 +48,8 @@ int main(int argc, char *argv[])
        unsigned char bsecret[20];
        unsigned char *secret = NULL;
        int i;
        unsigned char bsecret[20];
        unsigned char *secret = NULL;
        int i;
-       char *nonce = "1";
-       char *tokenid = "";
+       char *nonce = NULL;
+       char *tokenid = NULL;
        char *id = getlogin();
        char *payload = "";
        char *password = "";
        char *id = getlogin();
        char *payload = "";
        char *password = "";
@@ -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) {