diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-12-31 13:59:18 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-12-31 15:58:17 +0200 |
commit | 00e6c3c3ed06a258a02943fc49fa7c528025d747 (patch) | |
tree | 52530660be48fb5f4611bcc9393886bab8a70b72 | |
parent | 7f204cc788de3e03a51087b1273deb5b59288cf2 (diff) | |
download | pies-00e6c3c3ed06a258a02943fc49fa7c528025d747.tar.gz pies-00e6c3c3ed06a258a02943fc49fa7c528025d747.tar.bz2 |
Command-line control interface.
* configure.ac (DEFAULT_CONTROL_URL): New subst variable.
* grecs: Upgrade.
* ident/pam.c (overwrite_and_free): Free ptr.
* lib/Makefile.am: Add new sources.
* src/addrfmt.c: Move to lib/addrfmt.c
* lib/grecsasrt.c: New file.
* lib/grecsasrt.h: New file.
* lib/mkfilename.c: New file.
* lib/netrc.c: New file.
* lib/pp.c: New file.
* lib/split3.c: New file.
* src/url.c: Move from lib/url.c
(pies_url_free_user, pies_url_free_passwd): New finctions.
* lib/libpies.h (strsplit3): New proto.
(pies_url_create, pies_url_destroy)
(pies_url_get_arg, pies_url_copy)
(pies_url_free_user, pies_url_free_passwd)
(netrc_scan)
(pp_add_option, pp_command_line, mkfilename)
(sockaddr_to_str, sockaddr_to_astr): New protos
* src/Makefile.am (bin_PROGRAMS): New program: piesctl
(pies_SOURCES): Remove addrfmt.c and url.c.
(noinst_HEADERS, BUILT_SOURCES): Add piesctl-cl.h
* src/cmdline.opt: Use pp_* function family to build
preprocessor command line.
* src/ctl.c (http_header_hash): Use case-insensitive hashing.
(ctlio_finalize_reply): Don't close connection after sending 401
response.
(input): Remove ws and wsflags. All uses changed.
(input_append): Use strsplit3 to parse the request line.
* src/pies.c: Use pp_* function family to build
preprocessor command line.
Move assert_, mkfilename and _cb+_url functions into libpies.
* src/pies.h (pies_sockaddr_storage): Move to libpies.h
* src/piesctl.c: New file.
* src/piesctl-cl.opt: New file.
-rw-r--r-- | configure.ac | 4 | ||||
m--------- | grecs | 0 | ||||
-rw-r--r-- | ident/pam.c | 3 | ||||
-rw-r--r-- | lib/Makefile.am | 23 | ||||
-rw-r--r-- | lib/addrfmt.c (renamed from src/addrfmt.c) | 63 | ||||
-rw-r--r-- | lib/grecsasrt.c | 78 | ||||
-rw-r--r-- | lib/grecsasrt.h | 22 | ||||
-rw-r--r-- | lib/libpies.h | 66 | ||||
-rw-r--r-- | lib/mkfilename.c | 42 | ||||
-rw-r--r-- | lib/netrc.c | 217 | ||||
-rw-r--r-- | lib/pp.c | 71 | ||||
-rw-r--r-- | lib/split3.c | 83 | ||||
-rw-r--r-- | lib/url.c (renamed from src/url.c) | 94 | ||||
-rw-r--r-- | src/.gitignore | 2 | ||||
-rw-r--r-- | src/Makefile.am | 21 | ||||
-rw-r--r-- | src/cmdline.opt | 4 | ||||
-rw-r--r-- | src/ctl.c | 43 | ||||
-rw-r--r-- | src/pies.c | 121 | ||||
-rw-r--r-- | src/pies.h | 37 | ||||
-rw-r--r-- | src/piesctl-cl.opt | 95 | ||||
-rw-r--r-- | src/piesctl.c | 1067 |
21 files changed, 1937 insertions, 219 deletions
diff --git a/configure.ac b/configure.ac index 1e5ba2a..1ee26ec 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -132,6 +132,10 @@ AH_BOTTOM([ | |||
132 | # endif | 132 | # endif |
133 | ]) | 133 | ]) |
134 | 134 | ||
135 | AC_SUBST([DEFAULT_CONTROL_URL],[unix:///tmp/%s.ctl]) | ||
136 | AC_ARG_VAR([DEFAULT_CONTROL_URL], | ||
137 | [URL of the default control socket]) | ||
138 | |||
135 | IMPRIMATUR_INIT | 139 | IMPRIMATUR_INIT |
136 | 140 | ||
137 | AC_CONFIG_FILES([Makefile | 141 | AC_CONFIG_FILES([Makefile |
diff --git a/grecs b/grecs | |||
Subproject 8312f45f48ed9d995a15ee6707257f4c8946528 | Subproject 3b73967c62da68d865f32ca91c8407e65b8ddc0 | ||
diff --git a/ident/pam.c b/ident/pam.c index b7b9ef4..7302242 100644 --- a/ident/pam.c +++ b/ident/pam.c | |||
@@ -36,7 +36,8 @@ struct pam_cred | |||
36 | char *s = ptr; \ | 36 | char *s = ptr; \ |
37 | while (*s) \ | 37 | while (*s) \ |
38 | *s++ = 0; \ | 38 | *s++ = 0; \ |
39 | } while (0) | 39 | free (ptr); \ |
40 | } while (0) | ||
40 | 41 | ||
41 | #ifndef PAM_AUTHTOK_RECOVER_ERR | 42 | #ifndef PAM_AUTHTOK_RECOVER_ERR |
42 | # define PAM_AUTHTOK_RECOVER_ERR PAM_CONV_ERR | 43 | # define PAM_AUTHTOK_RECOVER_ERR PAM_CONV_ERR |
diff --git a/lib/Makefile.am b/lib/Makefile.am index 89812ca..a0d6614 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am | |||
@@ -1,5 +1,5 @@ | |||
1 | # This file is part of GNU Pies. | 1 | # This file is part of GNU Pies. |
2 | # Copyright (C) 2005, 2006, 2007, 2008, 2010, 2013 Sergey Poznyakoff | 2 | # Copyright (C) 2005-2008, 2010, 2013, 2015 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # GNU Pies is free software; you can redistribute it and/or modify | 4 | # GNU Pies 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 |
@@ -16,15 +16,28 @@ | |||
16 | 16 | ||
17 | noinst_LIBRARIES=libpies.a | 17 | noinst_LIBRARIES=libpies.a |
18 | 18 | ||
19 | noinst_HEADERS = libpies.h | 19 | noinst_HEADERS = libpies.h grecsasrt.h |
20 | 20 | ||
21 | libpies_a_SOURCES=\ | 21 | libpies_a_SOURCES=\ |
22 | addrfmt.c\ | ||
22 | arraymember.c\ | 23 | arraymember.c\ |
24 | grecsasrt.c\ | ||
25 | mkfilename.c\ | ||
26 | netrc.c\ | ||
23 | parsetime.c\ | 27 | parsetime.c\ |
24 | proctitle.c\ | 28 | proctitle.c\ |
25 | strtotok.c | 29 | pp.c\ |
30 | split3.c\ | ||
31 | strtotok.c\ | ||
32 | url.c | ||
26 | 33 | ||
27 | libpies_a_LIBADD=$(LIBOBJS) | 34 | libpies_a_LIBADD=\ |
35 | $(LIBOBJS)\ | ||
36 | @GRECS_LDADD@ | ||
28 | 37 | ||
29 | AM_CPPFLAGS = -I$(top_srcdir)/gnu -I../gnu | 38 | AM_CPPFLAGS = \ |
39 | -I$(top_srcdir)/gnu\ | ||
40 | -I../gnu\ | ||
41 | @GRECS_INCLUDES@\ | ||
42 | -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" | ||
30 | 43 | ||
diff --git a/src/addrfmt.c b/lib/addrfmt.c index 59754ae..ff615dd 100644 --- a/src/addrfmt.c +++ b/lib/addrfmt.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* This file is part of GNU Pies | 1 | /* This file is part of GNU Pies |
2 | Copyright (C) 2009, 2010, 2013 Sergey Poznyakoff | 2 | Copyright (C) 2009, 2010, 2013, 2015 Sergey Poznyakoff |
3 | 3 | ||
4 | GNU Pies is free software; you can redistribute it and/or modify | 4 | GNU Pies 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 |
@@ -17,7 +17,7 @@ | |||
17 | #ifdef HAVE_CONFIG_H | 17 | #ifdef HAVE_CONFIG_H |
18 | # include <config.h> | 18 | # include <config.h> |
19 | #endif | 19 | #endif |
20 | #include "pies.h" | 20 | #include "libpies.h" |
21 | #include <sys/types.h> | 21 | #include <sys/types.h> |
22 | #include <sys/socket.h> | 22 | #include <sys/socket.h> |
23 | #include <sys/time.h> | 23 | #include <sys/time.h> |
@@ -37,7 +37,7 @@ str2port (char *str) | |||
37 | serv = getservbyname (str, "tcp"); | 37 | serv = getservbyname (str, "tcp"); |
38 | 38 | ||
39 | if (serv != NULL) | 39 | if (serv != NULL) |
40 | port = ntohs(serv->s_port); | 40 | port = ntohs (serv->s_port); |
41 | else | 41 | else |
42 | { | 42 | { |
43 | unsigned long l; | 43 | unsigned long l; |
@@ -79,22 +79,61 @@ _my_stpcpy (char **pbuf, size_t *psize, const char *src) | |||
79 | #define S_UN_NAME(sa, salen) \ | 79 | #define S_UN_NAME(sa, salen) \ |
80 | ((salen < offsetof (struct sockaddr_un,sun_path)) ? "" : (sa)->sun_path) | 80 | ((salen < offsetof (struct sockaddr_un,sun_path)) ? "" : (sa)->sun_path) |
81 | 81 | ||
82 | static size_t | ||
83 | format_uint (char **bufptr, size_t *buflen, unsigned n) | ||
84 | { | ||
85 | char *buf = *bufptr; | ||
86 | size_t len = *buflen; | ||
87 | size_t i; | ||
88 | |||
89 | if (buf && len == 0) | ||
90 | return 0; | ||
91 | |||
92 | for (i = 0;;) | ||
93 | { | ||
94 | unsigned x = n % 10; | ||
95 | if (buf) | ||
96 | { | ||
97 | if (len == 1) | ||
98 | break; | ||
99 | *buf++ = x + '0'; | ||
100 | --len; | ||
101 | } | ||
102 | n /= 10; | ||
103 | ++i; | ||
104 | if (n == 0) | ||
105 | break; | ||
106 | } | ||
107 | |||
108 | if (buf) | ||
109 | { | ||
110 | char *p = *bufptr; | ||
111 | *bufptr = buf; | ||
112 | *buf = 0; | ||
113 | while (--buf > p) | ||
114 | { | ||
115 | char c = *p; | ||
116 | *p++ = *buf; | ||
117 | *buf = c; | ||
118 | } | ||
119 | } | ||
120 | return i; | ||
121 | } | ||
122 | |||
82 | void | 123 | void |
83 | sockaddr_to_str (const struct sockaddr *sa, int salen, | 124 | sockaddr_to_str (const struct sockaddr *sa, int salen, |
84 | char *bufptr, size_t buflen, | 125 | char *bufptr, size_t buflen, |
85 | size_t *plen) | 126 | size_t *plen) |
86 | { | 127 | { |
87 | char buf[INT_BUFSIZE_BOUND (uintmax_t)]; /* FIXME: too much */ | ||
88 | size_t len = 0; | 128 | size_t len = 0; |
89 | switch (sa->sa_family) | 129 | switch (sa->sa_family) |
90 | { | 130 | { |
91 | case AF_INET: | 131 | case AF_INET: |
92 | { | 132 | { |
93 | struct sockaddr_in s_in = *(struct sockaddr_in *)sa; | 133 | struct sockaddr_in s_in = *(struct sockaddr_in *)sa; |
94 | len += _my_stpcpy (&bufptr, &buflen, inet_ntoa(s_in.sin_addr)); | 134 | len += _my_stpcpy (&bufptr, &buflen, inet_ntoa (s_in.sin_addr)); |
95 | len += _my_stpcpy (&bufptr, &buflen, ":"); | 135 | len += _my_stpcpy (&bufptr, &buflen, ":"); |
96 | len += _my_stpcpy (&bufptr, &buflen, | 136 | len += format_uint (&bufptr, &buflen, ntohs (s_in.sin_port)); |
97 | umaxtostr(ntohs (s_in.sin_port), buf)); | ||
98 | break; | 137 | break; |
99 | } | 138 | } |
100 | 139 | ||
@@ -113,7 +152,7 @@ sockaddr_to_str (const struct sockaddr *sa, int salen, | |||
113 | 152 | ||
114 | default: | 153 | default: |
115 | len += _my_stpcpy (&bufptr, &buflen, "{Unsupported family: "); | 154 | len += _my_stpcpy (&bufptr, &buflen, "{Unsupported family: "); |
116 | len += _my_stpcpy (&bufptr, &buflen, umaxtostr (sa->sa_family, buf)); | 155 | len += format_uint (&bufptr, &buflen, sa->sa_family); |
117 | len += _my_stpcpy (&bufptr, &buflen, "}"); | 156 | len += _my_stpcpy (&bufptr, &buflen, "}"); |
118 | } | 157 | } |
119 | if (plen) | 158 | if (plen) |
@@ -126,8 +165,10 @@ sockaddr_to_astr (const struct sockaddr *sa, int salen) | |||
126 | size_t size; | 165 | size_t size; |
127 | char *p; | 166 | char *p; |
128 | 167 | ||
129 | sockaddr_to_str(sa, salen, NULL, 0, &size); | 168 | sockaddr_to_str (sa, salen, NULL, 0, &size); |
130 | p = xmalloc (size); | 169 | p = malloc (size); |
131 | sockaddr_to_str(sa, salen, p, size, NULL); | 170 | if (!p) |
171 | grecs_alloc_die (); | ||
172 | sockaddr_to_str (sa, salen, p, size, NULL); | ||
132< |