summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2017-11-10 09:08:35 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-11-10 09:08:35 (GMT)
commit2f1214a79a6befb629466c3e81a993123733a2fe (patch) (unidiff)
treeacf5e1cc9289cf4b655aa873d0b01642090b1391
parent3457c19206858d3e8155dcfc776df8818d05824b (diff)
downloadsmap-2f1214a79a6befb629466c3e81a993123733a2fe.tar.gz
smap-2f1214a79a6befb629466c3e81a993123733a2fe.tar.bz2
Placate cc warnings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/parseopt.c5
-rw-r--r--lib/sockmapstr.c2
-rw-r--r--lib/stream.c4
-rw-r--r--modules/ldap/ldap.c23
-rw-r--r--src/smapc.c2
-rw-r--r--src/userprivs.c2
6 files changed, 15 insertions, 23 deletions
diff --git a/lib/parseopt.c b/lib/parseopt.c
index cc0c9a6..cf5319d 100644
--- a/lib/parseopt.c
+++ b/lib/parseopt.c
@@ -1,8 +1,8 @@
1/* This file is part of Smap. 1/* This file is part of Smap.
2 Copyright (C) 2008, 2010, 2014 Sergey Poznyakoff 2 Copyright (C) 2008, 2010, 2014, 2017 Sergey Poznyakoff
3 3
4 Smap is free software; you can redistribute it and/or modify 4 Smap is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option) 6 the Free Software Foundation; either version 3, or (at your option)
7 any later version. 7 any later version.
8 8
@@ -17,12 +17,13 @@
17#ifdef HAVE_CONFIG_H 17#ifdef HAVE_CONFIG_H
18# include <config.h> 18# include <config.h>
19#endif 19#endif
20#include <smap/parseopt.h> 20#include <smap/parseopt.h>
21#include <smap/diag.h> 21#include <smap/diag.h>
22#include <string.h> 22#include <string.h>
23#include <ctype.h>
23 24
24static struct smap_option const * 25static struct smap_option const *
25find_opt(struct smap_option const *opt, const char *str, const char **value, 26find_opt(struct smap_option const *opt, const char *str, const char **value,
26 int flags) 27 int flags)
27{ 28{
28 size_t len = strlen(str); 29 size_t len = strlen(str);
@@ -172,14 +173,12 @@ smap_parseline(struct smap_option const *opt, const char *line, int flags,
172 173
173int 174int
174smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags, 175smap_parseopt(struct smap_option const *opt, int argc, char **argv, int flags,
175 int *pindex) 176 int *pindex)
176{ 177{
177 int i; 178 int i;
178 long n;
179 char *s;
180 int rc = 0; 179 int rc = 0;
181 const char *modname = argv[0]; 180 const char *modname = argv[0];
182 181
183 for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1; 182 for (i = (flags & SMAP_PARSEOPT_PARSE_ARGV0) ? 0 : 1;
184 i < argc; i++) { 183 i < argc; i++) {
185 char *errmsg; 184 char *errmsg;
diff --git a/lib/sockmapstr.c b/lib/sockmapstr.c
index 1c0d749..7e188f2 100644
--- a/lib/sockmapstr.c
+++ b/lib/sockmapstr.c
@@ -224,13 +224,13 @@ read_payload_length(struct sockmap_input_stream *sp)
224 strerror(errno))); 224 strerror(errno)));
225 return errno; 225 return errno;
226 } 226 }
227 if (n == 0) 227 if (n == 0)
228 return EOF; 228 return EOF;
229 len += n; 229 len += n;
230 if (p = memchr(sp->nbuf, ':', len)) { 230 if ((p = memchr(sp->nbuf, ':', len))) {
231 sp->cp = p - sp->nbuf; 231 sp->cp = p - sp->nbuf;
232 sp->nbuf[len] = 0; 232 sp->nbuf[len] = 0;
233 sp->nlen = len; 233 sp->nlen = len;
234 return 0; 234 return 0;
235 } 235 }
236 } 236 }
diff --git a/lib/stream.c b/lib/stream.c
index d039c08..c217ca6 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -222,18 +222,18 @@ _stream_flush_buffer(struct _smap_stream *stream, int all)
222 if (rc) 222 if (rc)
223 return rc; 223 return rc;
224 _stream_advance_buffer(stream, size); 224 _stream_advance_buffer(stream, size);
225 } 225 }
226 if (stream->level) { 226 if (stream->level) {
227 if (all) { 227 if (all) {
228 if (rc = _force_flush_buffer(stream)) 228 if ((rc = _force_flush_buffer(stream)))
229 return rc; 229 return rc;
230 } else if (BUFFER_FULL_P(stream)) { 230 } else if (BUFFER_FULL_P(stream)) {
231 if (stream->flags & SMAP_STREAM_EXPBUF) 231 if (stream->flags & SMAP_STREAM_EXPBUF)
232 return _stream_realloc_buffer(stream, 0); 232 return _stream_realloc_buffer(stream, 0);
233 if (rc = _force_flush_buffer(stream)) 233 if ((rc = _force_flush_buffer(stream)))
234 return rc; 234 return rc;
235 } 235 }
236 } 236 }
237 } 237 }
238 } else if (all) 238 } else if (all)
239 _stream_advance_buffer(stream, stream->level); 239 _stream_advance_buffer(stream, stream->level);
diff --git a/modules/ldap/ldap.c b/modules/ldap/ldap.c
index d686f6b..b34c560 100644
--- a/modules/ldap/ldap.c
+++ b/modules/ldap/ldap.c
@@ -105,13 +105,13 @@ argz_copy(char ***dst, char **a)
105 return 0; 105 return 0;
106 } 106 }
107 107
108 for (n = 0; a[n]; n++) 108 for (n = 0; a[n]; n++)
109 ; 109 ;
110 110
111 b = calloc(i + 1, sizeof(b[0])); 111 b = calloc(n + 1, sizeof(b[0]));
112 if (!b) 112 if (!b)
113 return -1; 113 return -1;
114 for (i = 0; i < n; i++) { 114 for (i = 0; i < n; i++) {
115 b[i] = strdup(a[i]); 115 b[i] = strdup(a[i]);
116 if (!b[i]) 116 if (!b[i])
117 return -1; 117 return -1;
@@ -197,13 +197,13 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
197 smap_error("can't open LDAP config file %s: %s", 197 smap_error("can't open LDAP config file %s: %s",
198 name, strerror(errno)); 198 name, strerror(errno));
199 return -1; 199 return -1;
200 } 200 }
201 201
202 line = 0; 202 line = 0;
203 while (p = fgets(buf, sizeof(buf), fp)) { 203 while ((p = fgets(buf, sizeof(buf), fp))) {
204 size_t len; 204 size_t len;
205 char *errmsg; 205 char *errmsg;
206 206
207 ++line; 207 ++line;
208 208
209 while (*p && isspace(*p)) 209 while (*p && isspace(*p))
@@ -251,20 +251,22 @@ parse_ldap_conf(const char *name, struct smap_option const *opt)
251 } 251 }
252 252
253 fclose(fp); 253 fclose(fp);
254 return rc; 254 return rc;
255} 255}
256 256
257#if 0
257static int 258static int
258readconf(struct smap_option const *opt, const char *val, char **errmsg) 259readconf(struct smap_option const *opt, const char *val, char **errmsg)
259{ 260{
260 int rc = parse_ldap_conf(val, opt); 261 int rc = parse_ldap_conf(val, opt);
261 if (rc) 262 if (rc)
262 *errmsg = "parse error"; 263 *errmsg = "parse error";
263 return rc; 264 return rc;
264} 265}
266#endif
265 267
266#define MKOPT_DEFAULT 0 268#define MKOPT_DEFAULT 0
267#define MKOPT_REUSE 0x01 269#define MKOPT_REUSE 0x01
268#define MKOPT_RESET 0x02 270#define MKOPT_RESET 0x02
269 271
270static int 272static int
@@ -499,14 +501,12 @@ parse_ldap_uri(const char *uri)
499static LDAP * 501static LDAP *
500ldap_connect(struct ldap_conf *conf) 502ldap_connect(struct ldap_conf *conf)
501{ 503{
502 int rc; 504 int rc;
503 char *ldapuri = NULL; 505 char *ldapuri = NULL;
504 LDAP *ld = NULL; 506 LDAP *ld = NULL;
505 char *val;
506 unsigned long lval;
507 507
508 if (ldap_debug_level) { 508 if (ldap_debug_level) {
509 if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL, 509 if (ber_set_option(NULL, LBER_OPT_DEBUG_LEVEL,
510 &ldap_debug_level) 510 &ldap_debug_level)
511 != LBER_OPT_SUCCESS ) 511 != LBER_OPT_SUCCESS )
512 smap_error("cannot set LBER_OPT_DEBUG_LEVEL %d", 512 smap_error("cannot set LBER_OPT_DEBUG_LEVEL %d",
@@ -602,39 +602,37 @@ full_read(int fd, char *file, char *buf, size_t size)
602 return 0; 602 return 0;
603} 603}
604 604
605static int 605static int
606get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc) 606get_passwd(struct ldap_conf *conf, struct berval *pwd, char **palloc)
607{ 607{
608 char *file;
609
610 if (conf->bindpwfile) { 608 if (conf->bindpwfile) {
611 struct stat st; 609 struct stat st;
612 int fd, rc; 610 int fd, rc;
613 char *mem, *p; 611 char *mem, *p;
614 612
615 fd = open(file, O_RDONLY); 613 fd = open(conf->bindpwfile, O_RDONLY);
616 if (fd == -1) { 614 if (fd == -1) {
617 smap_error("can't open password file %s: %s", 615 smap_error("can't open password file %s: %s",
618 file, strerror(errno)); 616 conf->bindpwfile, strerror(errno));
619 return -1; 617 return -1;
620 } 618 }
621 if (fstat(fd, &st)) { 619 if (fstat(fd, &st)) {
622 smap_error("can't stat password file %s: %s", 620 smap_error("can't stat password file %s: %s",
623 file, strerror(errno)); 621 conf->bindpwfile, strerror(errno));
624 close(fd); 622 close(fd);
625 return -1; 623 return -1;
626 } 624 }
627 mem = malloc(st.st_size + 1); 625 mem = malloc(st.st_size + 1);
628 if (!mem) { 626 if (!mem) {
629 smap_error("can't allocate memory (%lu bytes)", 627 smap_error("can't allocate memory (%lu bytes)",
630 (unsigned long) st.st_size+1); 628 (unsigned long) st.st_size+1);
631 close(fd); 629 close(fd);
632 return -1; 630 return -1;
633 } 631 }
634 rc = full_read(fd, file, mem, st.st_size); 632 rc = full_read(fd, conf->bindpwfile, mem, st.st_size);
635 close(fd); 633 close(fd);
636 if (rc) 634 if (rc)
637 return rc; 635 return rc;
638 mem[st.st_size] = 0; 636 mem[st.st_size] = 0;
639 p = strchr(mem, '\n'); 637 p = strchr(mem, '\n');
640 if (p) 638 if (p)
@@ -728,13 +726,12 @@ ldap_bind(LDAP *ld, struct ldap_conf *conf)
728} 726}
729 727
730 728
731static smap_database_t 729static smap_database_t
732mod_ldap_init_db(const char *dbid, int argc, char **argv) 730mod_ldap_init_db(const char *dbid, int argc, char **argv)
733{ 731{
734 LDAP *ldap;
735 struct ldap_db *db; 732 struct ldap_db *db;
736 struct ldap_conf conf; 733 struct ldap_conf conf;
737 size_t i, j; 734 size_t i, j;
738 struct smap_option *opt; 735 struct smap_option *opt;
739 736
740 if (!ldap_conf_cpy(&conf, &dfl_conf)) 737 if (!ldap_conf_cpy(&conf, &dfl_conf))
@@ -877,13 +874,12 @@ getvar(const char *var, size_t len, void *data)
877 if (strlen(gd->env[i]) == len 874 if (strlen(gd->env[i]) == len
878 && memcmp(var, gd->env[i], len) == 0) 875 && memcmp(var, gd->env[i], len) == 0)
879 return strdup(gd->env[i+1]); 876 return strdup(gd->env[i+1]);
880 } 877 }
881 878
882 if (gd->ld) { 879 if (gd->ld) {
883 struct berval bv;
884 char *p; 880 char *p;
885 struct berval **values; 881 struct berval **values;
886 char *attr = malloc(len+1); 882 char *attr = malloc(len+1);
887 883
888 if (!attr) 884 if (!attr)
889 return NULL; 885 return NULL;
@@ -986,18 +982,15 @@ mod_ldap_query(smap_database_t dbp,
986 smap_stream_t ostr, 982 smap_stream_t ostr,
987 const char *map, const char *key, 983 const char *map, const char *key,
988 struct smap_conninfo const *conninfo) 984 struct smap_conninfo const *conninfo)
989{ 985{
990 struct ldap_db *db = (struct ldap_db *) dbp; 986 struct ldap_db *db = (struct ldap_db *) dbp;
991 char const *inenv[5]; 987 char const *inenv[5];
992 char **env;
993 char **attrs;
994 struct wordsplit ws; 988 struct wordsplit ws;
995 ber_int_t msgid; 989 ber_int_t msgid;
996 int rc; 990 int rc;
997 char *reply = NULL;
998 LDAPMessage *res, *msg; 991 LDAPMessage *res, *msg;
999 992
1000# define __smap_s_cat2__(a,b) a ## b 993# define __smap_s_cat2__(a,b) a ## b
1001# define REPLY(d,s) \ 994# define REPLY(d,s) \
1002 ((d)->conf.__smap_s_cat2__(s,_reply) \ 995 ((d)->conf.__smap_s_cat2__(s,_reply) \
1003 ? (d)->conf.__smap_s_cat2__(s,_reply) \ 996 ? (d)->conf.__smap_s_cat2__(s,_reply) \
diff --git a/src/smapc.c b/src/smapc.c
index 88ddb0c..422afcd 100644
--- a/src/smapc.c
+++ b/src/smapc.c
@@ -647,13 +647,13 @@ read_eval_loop(FILE *fp, int interactive)
647 rl_attempted_completion_function = _command_completion; 647 rl_attempted_completion_function = _command_completion;
648 read_history(get_history_file_name()); 648 read_history(get_history_file_name());
649 } 649 }
650#endif 650#endif
651 if (interactive && !quiet_startup) 651 if (interactive && !quiet_startup)
652 shell_banner(); 652 shell_banner();
653 while (p = get_input_line(fp, interactive)) { 653 while ((p = get_input_line(fp, interactive))) {
654#ifdef WITH_READLINE 654#ifdef WITH_READLINE
655 if (interactive) { 655 if (interactive) {
656 if (retrieve_history(p)) 656 if (retrieve_history(p))
657 continue; 657 continue;
658 add_history(p); 658 add_history(p);
659 } 659 }
diff --git a/src/userprivs.c b/src/userprivs.c
index 46e546f..eb424fe 100644
--- a/src/userprivs.c
+++ b/src/userprivs.c
@@ -67,13 +67,13 @@ get_user_groups(struct privinfo *pi)
67 pw = getpwuid(pi->uid); 67 pw = getpwuid(pi->uid);
68 if (!pw) 68 if (!pw)
69 return; 69 return;
70 user = pw->pw_name; 70 user = pw->pw_name;
71 71
72 setgrent(); 72 setgrent();
73 while (gr = getgrent()) { 73 while ((gr = getgrent())) {
74 char **p; 74 char **p;
75 for (p = gr->gr_mem; *p; p++) 75 for (p = gr->gr_mem; *p; p++)
76 if (strcmp(*p, user) == 0) { 76 if (strcmp(*p, user) == 0) {
77 privinfo_add_grpgid(pi, gr->gr_gid); 77 privinfo_add_grpgid(pi, gr->gr_gid);
78 break; 78 break;
79 } 79 }

Return to:

Send suggestions and report system problems to the System administrator.