diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-17 18:36:54 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-02-17 18:36:54 +0200 |
commit | 317095181674a01651602ddf6817e888d0ad5280 (patch) | |
tree | da9a84a50223918408dfb578813c6fb098c1870c /src/verify.c | |
parent | 3277cd4abfa20e8b2499f052a6eb3792d8aa6cce (diff) | |
download | wydawca-317095181674a01651602ddf6817e888d0ad5280.tar.gz wydawca-317095181674a01651602ddf6817e888d0ad5280.tar.bz2 |
Begin rewriting method system
* src/builtin.c, src/builtin.h: New files.
* src/Makefile.am (wydawca_SOURCES): Add builtin.c and builtin.h
* src/config.c: New keyword access-method.query
* src/update-2.0.awk: Update.
* src/meta.c: Remove quote_string (replaced by method_quote_string).
(meta_escape): Add `handle' argument.
* src/method.c (struct method_descr): New methods: open, close, quote.
Updated methods: free, run, get. All callers updated.
(method_quote_string): New function.
* src/process.c (scan_directory_pair): Init all access methods at once.
* src/sql.c: Take name of the SQL connection from method->parmv[0].
Adapt to changes to the method subsystem.
* src/sql.h: Likewise.
* src/wydawca.h (struct access_method): New members id, parmc, parmv,
storage.
Remove union v.
(meta_escape): Take 3 arguments.
(method_new): Take 2 arguments.
(method_open, method_close, method_quote_string): New proto.
(method_run, method_result): Change signature.
* src/mail.c, src/triplet.c, src/verify.c
* etc/wydawca.rc: Update.
Diffstat (limited to 'src/verify.c')
-rw-r--r-- | src/verify.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/verify.c b/src/verify.c index cd0cb3f..9061532 100644 --- a/src/verify.c +++ b/src/verify.c @@ -100,6 +100,7 @@ check_access_rights (struct file_triplet *trp, struct directory_pair *dpair, char *command; const char *result; struct metadef def[5]; + void *md; if (fill_project_name (trp)) return 1; @@ -108,14 +109,19 @@ check_access_rights (struct file_triplet *trp, struct directory_pair *dpair, logmsg (LOG_DEBUG, "verifying access rights for user %s to project %s", user, trp->project); + md = method_open (method); + if (!md) + return 1; + make_default_meta (def, user, trp->project); - meta_escape (method, def); - command = meta_expand_string (method->param[1], def, NULL); + meta_escape (method, md, def); + command = meta_expand_string (method->query, def, NULL); meta_free (def); - rc = method_run (method, command); + rc = method_run (method, md, command); free (command); + method_close (method, md); if (rc) { logmsg (LOG_ERR, "Cannot verify access rights for %s on %s", @@ -123,7 +129,7 @@ check_access_rights (struct file_triplet *trp, struct directory_pair *dpair, return 1; } - result = method_result (method, 0, 0); + result = method_result (method, md, 0, 0); if (!result || strcmp (result, user)) { UPDATE_STATS (STAT_ACCESS_VIOLATIONS); @@ -145,37 +151,44 @@ verify_directive_file (struct file_triplet *trp, struct directory_pair *dpair) const char *pubkey; int rc; struct metadef def[5]; - + void *md; + if (!trp->file[file_directive].name) return 1; + md = method_open (method); + if (!md) + return 1; pw = getpwuid (TRIPLET_UID (trp)); if (!pw) { logmsg (LOG_ERR, "%s: getpwuid failed: %s", trp->name, strerror (errno)); + method_close (method, md); return 1; } trp->gid = pw->pw_gid; trp->user = xstrdup (pw->pw_name); make_default_meta (def, trp->user, NULL); - meta_escape (method, def); - command = meta_expand_string (method->param[1], def, NULL); + meta_escape (method, md, def); + command = meta_expand_string (method->query, def, NULL); meta_free (def); - rc = method_run (method, command); + rc = method_run (method, md, command); free (command); if (rc) { logmsg (LOG_ERR, "Cannot get PGP key for %s", trp->user); + method_close (method, md); return 1; } - pubkey = method_result (method, 0, 0); + pubkey = method_result (method, md, 0, 0); if (!pubkey || pubkey[0] == 0) { logmsg (LOG_ERR, "No GPG key for %s", trp->user); + method_close (method, md); return 1; } @@ -186,11 +199,14 @@ verify_directive_file (struct file_triplet *trp, struct directory_pair *dpair) { /*FIXME: Update stats */ logmsg (LOG_ERR, "invalid signature for %s", trp->name); + method_close (method, md); return 1; } else if (debug_level) logmsg (LOG_DEBUG, "%s: directive file signature OK", trp->name); - + + method_close (method, md); + if (debug_level > 1) { int i; |