From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 9 Aug 2022 12:00:55 +0000 (+0100) Subject: Strip off the last dot and everything to the right of it in the hostname when automat... X-Git-Tag: 4.1-rc1~24^2~42^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a774a6fcb0bf7daa550efbc9d9e2f1f2d7898731;p=thirdparty%2Fshairport-sync.git Strip off the last dot and everything to the right of it in the hostname when automatically generating a service name. --- diff --git a/shairport.c b/shairport.c index 91bc4416..b4ad115b 100644 --- a/shairport.c +++ b/shairport.c @@ -1454,6 +1454,11 @@ int parse_options(int argc, char **argv) { // now, do the substitutions in the service name char hostname[100]; gethostname(hostname, 100); + + // strip off a terminating ., e.g. .local from the hostname + char *last_dot = strrchr(hostname,'.'); + if (last_dot != NULL) + *last_dot = '\0'; char *i0; if (raw_service_name == NULL)