erofs-utils: lib: s3: support AWS SigV4 for S3 backend
PATCH v3 1/1 erofs-utils: lib: s3: support AWS SigV4 for S3 backend
From: Yifan Zhao <[email protected]>
This patch introduces support for AWS Signature Version 4 for s3erofs remote backend.
Now users can specify the folowing options:
- passwd_file=Y, S3 credentials file in the format $ak:$sk (optional);
- urlstyle=<vhost, path>, S3 API calling style (optional);
- sig=<2,4>, S3 API signature version (optional);
- region=W, region code for S3 endpoint (required for sig=4).
e.g.:
$ mkfs.erofs \ --s3=s3.amazonaws.com,urlstyle=vhost,sig=4,region=us-east-1 \ output.img \ noaa-goes19/ABI-Flood-Day-Shapefiles/2025/08/25/
Signed-off-by Yifan Zhao <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
---
Sorry about the delay.
Some minor styling fixes, will apply this version.
lib/liberofs_s3.h | 1 + lib/remotes/s3.c | 580 +++++++++++++++++++++++++++++++++++++--------- mkfs/main.c | 14 +- 3 files changed, 482 insertions(+), 113 deletions(-)
lib/liberofs_s3.h +1 -0
@@ -27,6 +27,7 @@ enum s3erofs_signature_version {struct erofs_s3 {void *easy_curl;const char *endpoint; +const char *region;char access_key[S3_ACCESS_KEY_LEN +1 ];char secret_key[S3_SECRET_KEY_LEN +1 ];
lib/remotes/s3.c +469 -111
843 lines not on this page · raw message
mkfs/main.c +12 -2
@@ -214,6 +214,7 @@ static void usage(int argc, char **argv)" [,passwd_file=Y] X=endpoint, Y=s3fs-compatible password file\n" " [,urlstyle=Z] S3 API calling style (Z = vhost|path) (default: vhost)\n" " [,sig=<2,4>] S3 API signature version (default: 2)\n" + " [,region=W] W=region code in which endpoint belongs to (required for sig=4)\n"#endif #ifdef OCIEROFS_ENABLED " --oci=[f|i] generate a full (f) or index-only (i) image from OCI remote source\n"
@@ -706,13 +707,17 @@ static int mkfs_parse_s3_cfg(char *cfg_str) }else if ((p =strstr (opt,"sig=" ))) { p +=strlen ("sig=" );if (strncmp (p,"4" ,1 ) ==0 ) { -erofs_warn ("AWS Signature Version 4 is not supported yet, using Version 2" ); + s3cfg.sig =S3EROFS_SIGNATURE_VERSION_4 ; }else if (strncmp (p,"2" ,1 ) ==0 ) { s3cfg.sig =S3EROFS_SIGNATURE_VERSION_2 ; }else { -erofs_err ("Invalid AWS Signature Version %s" , p); +erofs_err ("invalid AWS signature version %s" , p);return -EINVAL ; } + }else if ((p =strstr (opt,"region=" ))) { + p +=strlen ("region=" ); + opt =strchr (cfg_str,',' ); + s3cfg.region = opt ?strndup (p, opt - p) :strdup (p); }else {erofs_err ("invalid --s3 option %s" , opt);return -EINVAL ;
@@ -721,6 +726,11 @@ static int mkfs_parse_s3_cfg(char *cfg_str) opt = q ? q + 1 : NULL; } +if (s3cfg.sig ==S3EROFS_SIGNATURE_VERSION_4 && !s3cfg.region) { +erofs_err ("invalid --s3: using sig=4 requires region provided" ); +return -EINVAL ; + } +return 0 ; }#endif
Signature · 1 line
2.43.5