diff options
| author | sinanmohd <sinan@sinanmohd.com> | 2023-12-30 20:23:31 +0530 | 
|---|---|---|
| committer | sinanmohd <sinan@sinanmohd.com> | 2023-12-30 20:23:31 +0530 | 
| commit | 50b6b69fcfbe492d9bac3ed1c9d0cd7cc400a5de (patch) | |
| tree | b6c6a034c7ac78c62d94de78fdc6cba2a5e2a0f6 | |
| parent | 7960f6b6d80d64001282b7b0b43c0195645cc35c (diff) | |
pass/add: trim gpg fingerprint
| -rw-r--r-- | pass_util.c | 1 | ||||
| -rw-r--r-- | util.c | 12 | ||||
| -rw-r--r-- | util.h | 1 | 
3 files changed, 14 insertions, 0 deletions
| diff --git a/pass_util.c b/pass_util.c index d9d6fc3..3ce3784 100644 --- a/pass_util.c +++ b/pass_util.c @@ -145,6 +145,7 @@ int pass_add(const char *path, const char *pass, size_t n)  	if (!rc)  		err_die(1, "failed to read %s", gpg_id_path);  	fclose(gpg_id); +	util_strtrim(fpr);  	r = gpg_key_validate(fpr);  	if (r) @@ -2,6 +2,7 @@  #include <string.h>  #include <errno.h>  #include <linux/limits.h> +#include <ctype.h>  #include "util.h" @@ -31,3 +32,14 @@ int r_mkdir(const char *path, mode_t mode)  	return mkdir(path, mode);  } + +void util_strtrim(char *s) +{ +	char *rend; + +	for (rend = s; *s; ++s) +		if (!isspace(*s)) +			rend = s; + +	rend[1] = '\0'; +} @@ -11,6 +11,7 @@  }  int r_mkdir(const char *path, mode_t mode); +void util_strtrim(char *s);  #define UTIL_H  #endif | 
