aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-09-04 09:30:05 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-09-04 09:30:05 -0400
commite697056101dcd1461eee2bde3e169e4d7ddaec20 (patch)
treee16b237ada020c5fa2c0bf8f3afcff67c76ff528
parent4004b05ac3b2d0c29405d2b0ed7f9f08f8fd05dc (diff)
downloadmultihome-e697056101dcd1461eee2bde3e169e4d7ddaec20.tar.gz
Add strip_domainname to test_main
-rw-r--r--multihome.c18
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);