diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | configure.in | 12 | ||||
-rw-r--r-- | pk/gkr-pk-index.c | 33 | ||||
-rw-r--r-- | pkix/gkr-pkix-asn1.c | 30 |
4 files changed, 82 insertions, 0 deletions
@@ -1,3 +1,10 @@ +2007-12-06 Halton Huo <halton.huo@sun.com> + + Fix bug #501996 + * configure.in: check flock and timegm existence. + * pk/gkr-pk-index.c: (flock): Implement flock if flock not found. + * pkix/gkr-pkix-asn1.c: (timegm): Implement timegm if timegm not found. + 2007-12-06 Stef Walter <stef@memberwebs.com> * daemon/Makefile.am: diff --git a/configure.in b/configure.in index bf0a0893..7d0fc5f9 100644 --- a/configure.in +++ b/configure.in @@ -132,6 +132,18 @@ fi AC_CHECK_FUNCS(getpeerucred, AC_DEFINE(HAVE_GETPEERUCRED,1,[Have getpeerucred])) +# -------------------------------------------------------------------- +# Check for flock +# + +AC_CHECK_FUNCS(flock, AC_DEFINE(HAVE_FLOCK,1,[Have flock])) + +# -------------------------------------------------------------------- +# Check for timegm +# + +AC_CHECK_FUNCS(timegm, AC_DEFINE(HAVE_TIMEGM,1,[Have timegm])) + dnl mkdtemp replacement from gettext AC_REPLACE_FUNCS(mkdtemp) AC_STAT_MACROS_BROKEN diff --git a/pk/gkr-pk-index.c b/pk/gkr-pk-index.c index bf36d568..decc0067 100644 --- a/pk/gkr-pk-index.c +++ b/pk/gkr-pk-index.c @@ -68,6 +68,39 @@ static GQuark no_location = 0; * HELPERS */ +#ifndef HAVE_FLOCK +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_NB 4 +#define LOCK_UN 8 + +static int flock(int fd, int operation) +{ + struct flock flock; + + switch (operation & ~LOCK_NB) { + case LOCK_SH: + flock.l_type = F_RDLCK; + break; + case LOCK_EX: + flock.l_type = F_WRLCK; + break; + case LOCK_UN: + flock.l_type = F_UNLCK; + break; + default: + errno = EINVAL; + return -1; + } + + flock.l_whence = 0; + flock.l_start = 0; + flock.l_len = 0; + + return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &flock); +} +#endif //NOT_HAVE_FLOCK + static void free_mtime (gpointer v) { diff --git a/pkix/gkr-pkix-asn1.c b/pkix/gkr-pkix-asn1.c index fe7c4458..67bb9fc0 100644 --- a/pkix/gkr-pkix-asn1.c +++ b/pkix/gkr-pkix-asn1.c @@ -450,6 +450,36 @@ two_to_four_digit_year (int year) return century + year; } +#ifndef HAVE_TIMEGM +time_t timegm(struct tm *t) +{ + time_t tl, tb; + struct tm *tg; + + tl = mktime (t); + if (tl == -1) + { + t->tm_hour--; + tl = mktime (t); + if (tl == -1) + return -1; /* can't deal with output from strptime */ + tl += 3600; + } + tg = gmtime (&tl); + tg->tm_isdst = 0; + tb = mktime (tg); + if (tb == -1) + { + tg->tm_hour--; + tb = mktime (tg); + if (tb == -1) + return -1; /* can't deal with output from gmtime */ + tb += 3600; + } + return (tl - (tb - tl)); +} +#endif //NOT_HAVE_TIMEGM + time_t gkr_pkix_asn1_parse_utc_time (const gchar *time) { |