diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-04-16 14:22:50 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-04-16 14:22:50 +0000 |
commit | 0e02798b6506d81bff8aa3ce5c1f3af920f02531 (patch) | |
tree | 59900380b2fba793d13fda6dd4803327815b49cb /src/context.c | |
parent | 4066ff72ad86d39e4081ee5a89a6530061e8762b (diff) |
fix origin field of packages on update
git-svn-id: file:///home/lennart/svn/public/syrep/trunk@95 07ea20a6-d2c5-0310-9e02-9ef735347d72
Diffstat (limited to 'src/context.c')
-rw-r--r-- | src/context.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/context.c b/src/context.c index 6611d03..84dd4b1 100644 --- a/src/context.c +++ b/src/context.c @@ -160,8 +160,10 @@ struct syrep_db_context* db_context_open(const char *filename, int force) { if (!c->origin) { char hn[256]; - if (gethostname(hn, sizeof(hn)) < 0) + if (gethostname(hn, sizeof(hn)) < 0) { + fprintf(stderr, "gethostname() failed: %s\n", strerror(errno)); goto fail; + } c->origin = strdup(hn); } @@ -319,13 +321,32 @@ int db_context_save(struct syrep_db_context *c, const char *filename) { return package_save(c->package, filename); } +int db_context_fix_origin(struct syrep_db_context*c) { + char hn[256]; + assert(c); + + if (gethostname(hn, sizeof(hn)) < 0) { + fprintf(stderr, "gethostname() failed: %s\n", strerror(errno)); + return -1; + } + + free(c->origin); + c->origin = strdup(hn); + + return 0; +} + int db_context_origin_warn(struct syrep_db_context *c) { char hn[256]; assert(c); - if (gethostname(hn, sizeof(hn)) < 0) + if (gethostname(hn, sizeof(hn)) < 0) { + fprintf(stderr, "gethostname() failed: %s\n", strerror(errno)); return -1; + } + + hn[sizeof(hn)-1] = 0; if (strcmp(hn, c->origin)) { int q; |