diff options
Diffstat (limited to 'multihome.c')
-rw-r--r-- | multihome.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/multihome.c b/multihome.c index 906dab1..1514f0d 100644 --- a/multihome.c +++ b/multihome.c @@ -492,6 +492,11 @@ void user_transfer(int copy_mode) { fclose(fp); } +/** + * Retrieve hostname from FQDN + * @param hostname + * @return short hostname + */ char *strip_domainname(char *hostname) { char *ptr; char *nodename; @@ -565,12 +570,22 @@ void test_touch() { assert(access(input, F_OK) == 0); } +void test_strip_domainname() { + puts("strip_domainname()"); + char *input = "subdomain.domain.tld"; + char *result; + + result = strip_domainname(input); + assert(strncmp(input, result, strlen("subdomain")) == 0); +} + void test_main() { test_count_substrings(); test_split(); test_mkdirs(); test_shell(); test_touch(); + test_strip_domainname(); exit(0); } #endif @@ -666,7 +681,7 @@ int main(int argc, char *argv[]) { } #endif - // Get account name for the effective user + // Get effective user account information uid = geteuid(); if ((user_info = getpwuid(uid)) == NULL) { perror("getpwuid"); @@ -717,7 +732,6 @@ int main(int argc, char *argv[]) { copy_mode = arguments.update; // 0 = normal copy, 1 = update files - // Refuse to operate within a controlled home directory char already_inside[PATH_MAX]; sprintf(already_inside, "%s/%s", multihome.path_old, MULTIHOME_MARKER); |