aboutsummaryrefslogtreecommitdiffstats
path: root/src/repo/s6rc_repo_sanitize_svname.c
blob: 2d0fdb3b6f3025bef954d9cd5d729e139a253c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <string.h>

#include <skalibs/strerr.h>

#include <s6-rc/repo.h>

void s6rc_repo_sanitize_svname (char const *sv)
{
  if (!sv[0])
    strerr_dief2x(100, "service names cannot ", "be empty") ;
  if (sv[0] == '.')
    strerr_dief3x(100, "service names cannot ", "start with ", "a dot") ;
  if (strchr(sv, '/') || strchr(sv, '\n'))
    strerr_dief2x(100, "service names cannot ", "contain / or newlines") ;
  if (!strncmp(sv, "s6rc-", 5) || !strncmp(sv, "s6-rc-", 6))
    strerr_dief3x(100, "service names cannot ", "start with ", "reserved prefixes") ;
}