diff options
author | Pavel Březina <pbrezina@redhat.com> | 2013-08-03 01:02:02 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-09-05 11:14:17 +0200 |
commit | abac0f3ec2baa597d8e21a8744de6f33506299ce (patch) | |
tree | f556463763af11eb3d19251e19b3729a4ec82680 /src/util/util.c | |
parent | 002113460c411cab449c0d7dea824cea1a6c68e7 (diff) | |
download | sssd-abac0f3ec2baa597d8e21a8744de6f33506299ce.tar.gz sssd-abac0f3ec2baa597d8e21a8744de6f33506299ce.tar.xz sssd-abac0f3ec2baa597d8e21a8744de6f33506299ce.zip |
utils: add is_host_in_domain()
Diffstat (limited to 'src/util/util.c')
-rw-r--r-- | src/util/util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c index 480296766..fb3bed146 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -724,3 +724,18 @@ int domain_to_basedn(TALLOC_CTX *memctx, const char *domain, char **basedn) *basedn = dn; return EOK; } + +bool is_host_in_domain(const char *host, const char *domain) +{ + int diff = strlen(host) - strlen(domain); + + if (diff == 0 && strcmp(host, domain) == 0) { + return true; + } + + if (diff > 0 && strcmp(host + diff, domain) == 0 && host[diff - 1] == '.') { + return true; + } + + return false; +} |