1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
|
From f77c2cb1ea2b5087c4c0885bce6dde7b7306b300 Mon Sep 17 00:00:00 2001
From: Mattias Ellert <mattias.ellert@physics.uu.se>
Date: Sat, 23 Mar 2024 16:02:30 +0100
Subject: [PATCH] Support 64 bit time_t on 32 bit systems
---
src/canl_mod_gridsite.c | 110 ++++++++++++++++++++--------------------
src/grst_admin.h | 2 +-
src/grst_admin_file.c | 18 ++++---
src/grst_admin_main.c | 6 +--
src/grst_canl_x509.c | 31 +++++------
src/htproxyput.c | 2 +-
6 files changed, 86 insertions(+), 83 deletions(-)
diff --git a/src/canl_mod_gridsite.c b/src/canl_mod_gridsite.c
index 869bba9..4a42c8a 100644
--- a/src/canl_mod_gridsite.c
+++ b/src/canl_mod_gridsite.c
@@ -749,23 +749,23 @@ int html_dir_list(request_rec *r, mod_gridsite_dir_cfg *conf)
escaped = html_escape(r->pool, namelist[n]->d_name);
if (S_ISDIR(statbuf.st_mode))
- temp = apr_psprintf(r->pool,
- "<tr><td><a href=\"%s/\" content-length=\"%ld\" "
- "last-modified=\"%ld\">"
+ temp = apr_psprintf(r->pool,
+ "<tr><td><a href=\"%s/\" content-length=\"%lld\" "
+ "last-modified=\"%lld\">"
"%s/</a></td>"
- "<td align=right>%ld</td>%s</tr>\n",
- encoded, statbuf.st_size, statbuf.st_mtime,
- escaped,
- statbuf.st_size, modified);
- else temp = apr_psprintf(r->pool,
- "<tr><td><a href=\"%s\" content-length=\"%ld\" "
- "last-modified=\"%ld\">"
+ "<td align=right>%lld</td>%s</tr>\n",
+ encoded, (long long) statbuf.st_size,
+ (long long) statbuf.st_mtime, escaped,
+ (long long) statbuf.st_size, modified);
+ else temp = apr_psprintf(r->pool,
+ "<tr><td><a href=\"%s\" content-length=\"%lld\" "
+ "last-modified=\"%lld\">"
"%s</a></td>"
- "<td align=right>%ld</td>%s</tr>\n",
- encoded, statbuf.st_size, statbuf.st_mtime,
- escaped,
- statbuf.st_size, modified);
-
+ "<td align=right>%lld</td>%s</tr>\n",
+ encoded, (long long) statbuf.st_size,
+ (long long) statbuf.st_mtime, escaped,
+ (long long) statbuf.st_size, modified);
+
free(encoded);
/* escaped done with pool so no free() */
@@ -874,8 +874,8 @@ char *make_passcode_file(request_rec *r, mod_gridsite_dir_cfg *conf,
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"Created passcode file %s", filetemplate);
- if (expires_time > 0) apr_file_printf(fp, "expires=%lu\n",
- (time_t) apr_time_sec(expires_time));
+ if (expires_time > 0) apr_file_printf(fp, "expires=%lld\n",
+ (long long) apr_time_sec(expires_time));
apr_file_printf(fp, "domain=%s\npath=%s\n", r->hostname, path);
@@ -1290,19 +1290,19 @@ static void recurse4dirlist(char *dirname, time_t *dirs_time,
strftime(modified, sizeof(modified),
"<td align=right>%R</td><td align=right>%e %b %y</td>",
&mtime_tm);
-
+
mildencoded = GRSThttpUrlMildencode(&unencname[fullurilen]);
-
+
oneline = apr_psprintf(r->pool,
"<tr><td><a href=\"%s\" "
- "content-length=\"%ld\" "
- "last-modified=\"%ld\">"
+ "content-length=\"%lld\" "
+ "last-modified=\"%lld\">"
"%s</a></td>"
- "<td align=right>%ld</td>%s</tr>\n",
- mildencoded, statbuf.st_size,
- statbuf.st_mtime,
- html_escape(r->pool, unencname),
- statbuf.st_size, modified);
+ "<td align=right>%lld</td>%s</tr>\n",
+ mildencoded, (long long) statbuf.st_size,
+ (long long) statbuf.st_mtime,
+ html_escape(r->pool, unencname),
+ (long long) statbuf.st_size, modified);
free(mildencoded);
@@ -2486,16 +2486,16 @@ void GRST_save_ssl_creds(conn_rec *conn, GRSTx509Chain *grst_chain)
apr_table_setn(conn->notes,
apr_psprintf(conn->pool, "GRST_CRED_VALID_%d", i),
- apr_psprintf(conn->pool,
- "notbefore=%ld notafter=%ld delegation=%d nist-loa=%d",
- grst_cert->notbefore,
- grst_cert->notafter,
+ apr_psprintf(conn->pool,
+ "notbefore=%lld notafter=%lld delegation=%d nist-loa=%d",
+ (long long) grst_cert->notbefore,
+ (long long) grst_cert->notafter,
grst_cert->delegation, 0));
- if (fp != NULL) apr_file_printf(fp,
- "GRST_CRED_VALID_%d=notbefore=%ld notafter=%ld delegation=%d nist-loa=%d\n",
- i, grst_cert->notbefore,
- grst_cert->notafter,
+ if (fp != NULL) apr_file_printf(fp,
+ "GRST_CRED_VALID_%d=notbefore=%lld notafter=%lld delegation=%d nist-loa=%d\n",
+ i, (long long) grst_cert->notbefore,
+ (long long) grst_cert->notafter,
grst_cert->delegation, 0);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, conn->base_server,
@@ -2541,16 +2541,16 @@ void GRST_save_ssl_creds(conn_rec *conn, GRSTx509Chain *grst_chain)
apr_table_setn(conn->notes,
apr_psprintf(conn->pool, "GRST_CRED_VALID_%d", i),
- apr_psprintf(conn->pool,
- "notbefore=%ld notafter=%ld delegation=%d nist-loa=%d",
- grst_cert->notbefore,
- grst_cert->notafter,
+ apr_psprintf(conn->pool,
+ "notbefore=%lld notafter=%lld delegation=%d nist-loa=%d",
+ (long long) grst_cert->notbefore,
+ (long long) grst_cert->notafter,
grst_cert->delegation, 0));
- if (fp != NULL) apr_file_printf(fp,
- "GRST_CRED_VALID_%d=notbefore=%ld notafter=%ld delegation=%d nist-loa=%d\n",
- i, grst_cert->notbefore,
- grst_cert->notafter,
+ if (fp != NULL) apr_file_printf(fp,
+ "GRST_CRED_VALID_%d=notbefore=%lld notafter=%lld delegation=%d nist-loa=%d\n",
+ i, (long long) grst_cert->notbefore,
+ (long long) grst_cert->notafter,
grst_cert->delegation, 0);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, conn->base_server,
@@ -2713,7 +2713,7 @@ static int mod_gridsite_perm_handler(request_rec *r)
*aclpath = NULL, *grst_cred_valid_0 = NULL, *grst_cred_valid_i,
*gridauthpasscode = NULL, *grst_voms_fqans;
const char *content_type, *robot;
- time_t notbefore, notafter;
+ long long notbefore, notafter;
apr_table_t *env;
apr_finfo_t cookiefile_info;
apr_file_t *fp;
@@ -2889,7 +2889,7 @@ static int mod_gridsite_perm_handler(request_rec *r)
&& (j == i)
&& ((p = index(oneline, '=')) != NULL)
&& (sscanf(&p[1],
- "notbefore=%ld notafter=%ld delegation=%d nist-loa=%d",
+ "notbefore=%lld notafter=%lld delegation=%d nist-loa=%d",
¬before, ¬after, &delegation,
&nist_loa) == 4))
{
@@ -2945,7 +2945,7 @@ static int mod_gridsite_perm_handler(request_rec *r)
((grst_cred_valid_0 = (char *)
apr_table_get(r->connection->notes, "GRST_CRED_VALID_0")) != NULL) &&
(sscanf(grst_cred_valid_0,
- "notbefore=%ld notafter=%ld delegation=%d nist-loa=%d",
+ "notbefore=%lld notafter=%lld delegation=%d nist-loa=%d",
¬before, ¬after, &delegation, &nist_loa) == 4) &&
(delegation <= ((mod_gridsite_dir_cfg *) cfg)->gsiproxylimit) &&
((delegation > 0) ||
@@ -2988,7 +2988,7 @@ static int mod_gridsite_perm_handler(request_rec *r)
nist_loa = 0;
sscanf(grst_cred_valid_i,
- "notbefore=%ld notafter=%ld delegation=%d nist-loa=%d",
+ "notbefore=%lld notafter=%lld delegation=%d nist-loa=%d",
¬before, ¬after, &delegation, &nist_loa);
GRSTgaclCredSetNotBefore( cred, notbefore);
@@ -3104,10 +3104,10 @@ static int mod_gridsite_perm_handler(request_rec *r)
apr_table_setn(env,
apr_psprintf(r->pool, "GRST_CRED_%d", i),
apr_psprintf(r->pool,
- "%s %ld %ld %d %s",
+ "%s %lld %lld %d %s",
(i==0) ? "X509USER" : "GSIPROXY",
- cred->notbefore,
- cred->notafter,
+ (long long) cred->notbefore,
+ (long long) cred->notafter,
cc_delegation,
decoded));
free(decoded);
@@ -3118,7 +3118,7 @@ static int mod_gridsite_perm_handler(request_rec *r)
apr_table_setn(env,
apr_psprintf(r->pool, "GRST_CRED_%d", i),
apr_psprintf(r->pool,
- "VOMS %ld %ld 0 %s",
+ "VOMS %lld %lld 0 %s",
notbefore, notafter,
decoded));
free(decoded);
@@ -3131,9 +3131,9 @@ static int mod_gridsite_perm_handler(request_rec *r)
apr_table_setn(env,
apr_psprintf(r->pool, "GRST_CRED_VALID_%d", i),
apr_psprintf(r->pool,
- "notbefore=%ld notafter=%ld delegation=%d nist-loa=%d",
- cred->notbefore,
- cred->notafter,
+ "notbefore=%lld notafter=%lld delegation=%d nist-loa=%d",
+ (long long) cred->notbefore,
+ (long long) cred->notafter,
cred->delegation,
cred->nist_loa));
@@ -4042,8 +4042,8 @@ static void mod_gridsite_child_init(apr_pool_t *pPool, server_rec *pServer)
- apr_time_from_sec(sc->session_cache_timeout);
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, pServer,
- "Cutoff time for ssl creds cache: %ld",
- (long) apr_time_sec(cutoff_time));
+ "Cutoff time for ssl creds cache: %lld",
+ (long long) apr_time_sec(cutoff_time));
if (apr_dir_open(&dir,
ap_server_root_relative(pPool, sessionsdir), pPool) == APR_SUCCESS)
diff --git a/src/grst_admin.h b/src/grst_admin.h
index 8bf3bcf..9a14a04 100644
--- a/src/grst_admin.h
+++ b/src/grst_admin.h
@@ -36,7 +36,7 @@
void GRSThttpError(char *);
void adminfooter(GRSThttpBody *, char *, char *, char *, char *);
int GRSTstrCmpShort(char *, char *);
-char *makevfilename(char *, size_t, char *);
+char *makevfilename(char *, off_t, char *);
/*CGI GACL - Edit interface functions*/
void show_acl(int admin, GRSTgaclUser *user, char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path, char *file, char *dir_uri, char *admin_file);
diff --git a/src/grst_admin_file.c b/src/grst_admin_file.c
index 3806a14..db0de17 100644
--- a/src/grst_admin_file.c
+++ b/src/grst_admin_file.c
@@ -965,8 +965,8 @@ void printfile(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path,
fp = fopen(dir_path_file, "r");
if (fp == NULL) GRSThttpError("500 Internal server error");
- printf("Status: 200 OK\nContent-Type: text/html\nContent-Length: %ld\n\n",
- statbuf.st_size);
+ printf("Status: 200 OK\nContent-Type: text/html\nContent-Length: %lld\n\n",
+ (long long) statbuf.st_size);
while ((c = fgetc(fp)) != EOF) putchar(c);
@@ -980,8 +980,9 @@ void filehistory(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path,
int fd, n, i, j, enclen, num = 0;
char *encodedfile, *p, *dndecoded, modified[99], *vfile, *q,
*encdn;
- time_t file_time;
- size_t file_size;
+ long long file_time;
+ time_t file_time_t;
+ long long file_size;
struct stat statbuf;
struct dirent **namelist;
struct tm file_tm;
@@ -1037,10 +1038,11 @@ void filehistory(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path,
p = index(namelist[i]->d_name, ':');
p = index(&p[1], ':');
- sscanf(&p[1], "%lX:", &file_time);
+ sscanf(&p[1], "%llX:", &file_time);
+ file_time_t = file_time;
p = index(&p[1], ':'); /* skip over microseconds time */
p = index(&p[1], ':');
- sscanf(&p[1], "%zX:", &file_size);
+ sscanf(&p[1], "%llX:", &file_size);
p = index(&p[1], ':');
encdn = strdup(&p[1]);
@@ -1050,12 +1052,12 @@ void filehistory(char *dn, GRSTgaclPerm perm, char *help_uri, char *dir_path,
for (q=encdn; *q != '\0'; ++q) if (*q == '=') *q = '%';
dndecoded = GRSThttpUrlDecode(encdn);
- localtime_r((const time_t *) &file_time, &file_tm);
+ localtime_r(&file_time_t, &file_tm);
strftime(modified, sizeof(modified),
"%a %e %b %Y %k:%M", &file_tm);
GRSThttpPrintf(&bp,
- "<tr><td>%s</td><td align=right>%d</td><td>%s</td>\n",
+ "<tr><td>%s</td><td align=right>%lld</td><td>%s</td>\n",
modified, file_size, dndecoded);
free(dndecoded);
diff --git a/src/grst_admin_main.c b/src/grst_admin_main.c
index 05cc4b6..5223d62 100644
--- a/src/grst_admin_main.c
+++ b/src/grst_admin_main.c
@@ -141,7 +141,7 @@ int GRSTstrCmpShort(char *long_s, char *short_s)
return 0;
}
-char *makevfilename(char *publicname, size_t size, char *dn)
+char *makevfilename(char *publicname, off_t size, char *dn)
{
int i;
char *ext, *vfilename, *encpublicname, *encdn, *p;
@@ -161,8 +161,8 @@ char *makevfilename(char *publicname, size_t size, char *dn)
/* we used zero-padding for times so
alphanumeric sorting will sort chronologically too */
- asprintf(&vfilename, "%s:%s:%08lX:%05lX:%zX:%s:%s", GRST_HIST_PREFIX,
- encpublicname, tv_now.tv_sec, tv_now.tv_usec, size, encdn, ext);
+ asprintf(&vfilename, "%s:%s:%08llX:%05X:%llX:%s:%s", GRST_HIST_PREFIX,
+ encpublicname, (long long) tv_now.tv_sec, (int) tv_now.tv_usec, (long long) size, encdn, ext);
return vfilename;
}
diff --git a/src/grst_canl_x509.c b/src/grst_canl_x509.c
index 62d8142..1f46018 100644
--- a/src/grst_canl_x509.c
+++ b/src/grst_canl_x509.c
@@ -1520,8 +1520,8 @@ int GRSTx509ParseVomsExt(int *lastcred, int maxcreds, size_t credlen,
{
++(*lastcred);
snprintf(&creds[*lastcred * (credlen + 1)], credlen+1,
- "VOMS %010lu %010lu 0 %.*s",
- time1_time, time2_time,
+ "VOMS %010lld %010lld 0 %.*s",
+ (long long) time1_time, (long long) time2_time,
taglist[itag].length,
&asn1string[taglist[itag].start+
taglist[itag].headerlength]);
@@ -1599,7 +1599,8 @@ GRSTgaclCred *GRSTx509CompactToCred(char *grst_cred)
{
int delegation;
char *p, *encoded;
- time_t now, notbefore, notafter;
+ time_t now;
+ long long notbefore, notafter;
GRSTgaclCred *cred = NULL;
time(&now);
@@ -1608,7 +1609,7 @@ GRSTgaclCred *GRSTx509CompactToCred(char *grst_cred)
if (strncmp(grst_cred, "X509USER ", 9) == 0)
{
- if ((sscanf(grst_cred, "X509USER %lu %lu %d",
+ if ((sscanf(grst_cred, "X509USER %lld %lld %d",
¬before, ¬after, &delegation) == 3)
&& (now >= notbefore)
&& (now <= notafter)
@@ -1628,7 +1629,7 @@ GRSTgaclCred *GRSTx509CompactToCred(char *grst_cred)
if (strncmp(grst_cred, "VOMS ", 5) == 0)
{
- if ((sscanf(grst_cred, "VOMS %lu %lu %d",
+ if ((sscanf(grst_cred, "VOMS %lld %lld %d",
¬before, ¬after, &delegation) == 3)
&& (now >= notbefore)
&& (now <= notafter)
@@ -1700,12 +1701,12 @@ int GRSTx509CompactCreds(int *lastcred, int maxcreds, size_t credlen,
if ((usercert == NULL) /* if no usercert ("EEC"), we're not interested */
||
- (snprintf(credtemp, credlen+1, "X509USER %010lu %010lu %d %s",
- GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(usercert)),0),
- GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(usercert)),0),
+ (snprintf(credtemp, credlen+1, "X509USER %010lld %010lld %d %s",
+ (long long) GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(usercert)),0),
+ (long long) GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(usercert)),0),
delegation,
- X509_NAME_oneline(X509_get_subject_name(usercert), NULL, 0)) >= credlen+1)
- ||
+ X509_NAME_oneline(X509_get_subject_name(usercert), NULL, 0)) >= credlen+1)
+ ||
(*lastcred >= maxcreds-1))
{
*lastcred = -1; /* just in case the caller looks at it */
@@ -1717,11 +1718,11 @@ int GRSTx509CompactCreds(int *lastcred, int maxcreds, size_t credlen,
if ((gsiproxycert != NULL)
&&
- (snprintf(credtemp, credlen+1, "GSIPROXY %010lu %010lu %d %s",
- GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(gsiproxycert)),0),
- GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(gsiproxycert)),0),
- delegation,
- X509_NAME_oneline(X509_get_subject_name(gsiproxycert), NULL, 0)) < credlen+1)
+ (snprintf(credtemp, credlen+1, "GSIPROXY %010lld %010lld %d %s",
+ (long long) GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notBefore(gsiproxycert)),0),
+ (long long) GRSTasn1TimeToTimeT(ASN1_STRING_data(X509_get_notAfter(gsiproxycert)),0),
+ delegation,
+ X509_NAME_oneline(X509_get_subject_name(gsiproxycert), NULL, 0)) < credlen+1)
&&
(*lastcred < maxcreds-1))
{
diff --git a/src/htproxyput.c b/src/htproxyput.c
index b87ef33..17c50a7 100644
--- a/src/htproxyput.c
+++ b/src/htproxyput.c
@@ -469,7 +469,7 @@ int main(int argc, char *argv[])
if (method == HTPROXY_UNIXTIME)
- printf("%ld\n", getTerminationTimeResponse._getTerminationTimeReturn);
+ printf("%lld\n", (long long) getTerminationTimeResponse._getTerminationTimeReturn);
else
{
finish_tm =
--
2.44.0
|