client: possibly undefined variable value in certauth
[libisds.git] / client / changepassword.c
blob49e84c43e2317e36cc4d4c550567b882ca5d3767
1 #define _XOPEN_SOURCE 500
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <locale.h>
5 #include <time.h>
6 #include <string.h>
7 #include <isds.h>
8 #include "common.h"
10 void change_password(struct isds_ctx *ctx,
11 const char *old_password, const char *new_password) {
12 printf("Changing password to: `%s'\n", new_password);
13 if (old_password && new_password && !strcmp(new_password, password))
14 printf("(Same as old password)\n");
15 if (!old_password)
16 printf("(Old password omitted)\n");
17 isds_error err = isds_change_password(ctx, old_password, new_password);
18 if (err) {
19 printf("isds_change_password() failed: %s: %s\n",
20 isds_strerror(err), isds_long_message(ctx));
21 } else {
22 printf("isds_change_password() succeeded.\n"
23 "This should not happen");
25 printf("\n");
28 int main(int argc, char **argv) {
29 struct isds_ctx *ctx = NULL;
30 isds_error err;
32 setlocale(LC_ALL, "");
34 err = isds_init();
35 if (err) {
36 printf("isds_init() failed: %s\n", isds_strerror(err));
37 exit(EXIT_FAILURE);
40 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
42 ctx = isds_ctx_create();
43 if (!ctx) {
44 printf("isds_ctx_create() failed");
47 err = isds_set_timeout(ctx, 10000);
48 if (err) {
49 printf("isds_set_timeout() failed: %s\n", isds_strerror(err));
52 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
53 if (err) {
54 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
55 isds_strerror(err));
58 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
59 if (err) {
60 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
61 isds_strerror(err));
62 }*/
64 err = isds_login(ctx, url, username, password, NULL);
65 if (err) {
66 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
67 isds_long_message(ctx));
68 } else {
69 printf("Logged in :)\n");
73 /* Try some invalid invocation that should fail */
74 change_password(ctx, password, NULL);
75 change_password(ctx, password, "");
76 change_password(ctx, password, password);
80 err = isds_logout(ctx);
81 if (err) {
82 printf("isds_logout() failed: %s\n", isds_strerror(err));
86 err = isds_ctx_free(&ctx);
87 if (err) {
88 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
92 err = isds_cleanup();
93 if (err) {
94 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
97 exit (EXIT_SUCCESS);