aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-01-19 00:21:09 +0100
committerLibravatar Rutger Broekhoff2024-01-19 00:21:09 +0100
commit5156228f18f08255a1f5c7e22097b8e367881e19 (patch)
tree8caccbf4d6d47b9f365d091d5b3426c4e6f7dafa /cmd
parentb07332d62c347326baade26e3a3c281b83172615 (diff)
downloadgitolfs3-5156228f18f08255a1f5c7e22097b8e367881e19.tar.gz
gitolfs3-5156228f18f08255a1f5c7e22097b8e367881e19.zip
Rust code dump
Diffstat (limited to 'cmd')
-rw-r--r--cmd/git-lfs-authenticate/main.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/cmd/git-lfs-authenticate/main.c b/cmd/git-lfs-authenticate/main.c
index 71481e9..a7ec031 100644
--- a/cmd/git-lfs-authenticate/main.c
+++ b/cmd/git-lfs-authenticate/main.c
@@ -65,8 +65,6 @@ void checkrepopath(const char *path) {
65 die("Bad repository name: Is unresolved path"); 65 die("Bad repository name: Is unresolved path");
66 if (strlen(path) > 100) 66 if (strlen(path) > 100)
67 die("Bad repository name: Longer than 100 characters"); 67 die("Bad repository name: Longer than 100 characters");
68 if (hassuffix(path, "/"))
69 die("Bad repositry name: Unexpected trailing slash");
70 if (hasprefix(path, "/")) 68 if (hasprefix(path, "/"))
71 die("Bad repository name: Unexpected absolute path"); 69 die("Bad repository name: Unexpected absolute path");
72 if (!hassuffix(path, ".git")) 70 if (!hassuffix(path, ".git"))
@@ -152,6 +150,10 @@ void u64tobe(uint64_t x, uint8_t b[8]) {
152 b[7] = (uint8_t)(x >> 0); 150 b[7] = (uint8_t)(x >> 0);
153} 151}
154 152
153void *memcat(void *dest, const void *src, size_t n) {
154 return memcpy(dest, src, n) + n;
155}
156
155#define MAX_TAG_SIZE EVP_MAX_MD_SIZE 157#define MAX_TAG_SIZE EVP_MAX_MD_SIZE
156 158
157typedef struct taginfo { 159typedef struct taginfo {
@@ -161,10 +163,6 @@ typedef struct taginfo {
161 const int64_t expiresat_s; 163 const int64_t expiresat_s;
162} taginfo_t; 164} taginfo_t;
163 165
164void *memcat(void *dest, const void *src, size_t n) {
165 return memcpy(dest, src, n) + n;
166}
167
168void maketag(const taginfo_t info, uint8_t key[KEYSIZE], uint8_t dest[MAX_TAG_SIZE], uint32_t *len) { 166void maketag(const taginfo_t info, uint8_t key[KEYSIZE], uint8_t dest[MAX_TAG_SIZE], uint32_t *len) {
169 uint8_t expiresat_b[8]; 167 uint8_t expiresat_b[8];
170 u64tobe(info.expiresat_s, expiresat_b); 168 u64tobe(info.expiresat_s, expiresat_b);
@@ -247,7 +245,8 @@ int main(int argc, char *argv[]) {
247 char hextag[MAX_HEXTAG_STRLEN + 1]; 245 char hextag[MAX_HEXTAG_STRLEN + 1];
248 makehextag(taginfo, key, hextag); 246 makehextag(taginfo, key, hextag);
249 247
250 printf("{\"header\":{\"Authorization\":\"Gitolfs3-Hmac-Sha256 %s\"},\"expires_in\":%ld,\"href\":\"", hextag, expiresin_s); 248 printf("{\"header\":{\"Authorization\":\"Gitolfs3-Hmac-Sha256 %s\"},"
249 "\"expires_in\":%ld,\"href\":\"", hextag, expiresin_s);
251 printescjson(hrefbase); 250 printescjson(hrefbase);
252 printescjson(repopath); 251 printescjson(repopath);
253 printf("/info/lfs?p=1&te=%ld\"}\n", expiresat_s); 252 printf("/info/lfs?p=1&te=%ld\"}\n", expiresat_s);