summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/ldap_common.c
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2010-11-23 17:43:23 +0100
committerStephen Gallagher <sgallagh@redhat.com>2010-12-06 09:30:13 -0500
commit39875788b552ed157e68156e64e95dda5dc6aa43 (patch)
treec782c26c61e765ba2793c8d750aad04ec6231001 /src/providers/ldap/ldap_common.c
parentf414e7061d600a656c6773fd4e5e87dd561fae16 (diff)
downloadsssd-39875788b552ed157e68156e64e95dda5dc6aa43.tar.gz
sssd-39875788b552ed157e68156e64e95dda5dc6aa43.tar.xz
sssd-39875788b552ed157e68156e64e95dda5dc6aa43.zip
Make string_to_shadowpw_days() public
Diffstat (limited to 'src/providers/ldap/ldap_common.c')
-rw-r--r--src/providers/ldap/ldap_common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index aa0bac64f..d9d44c899 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -738,3 +738,37 @@ done:
talloc_zfree(tmp_ctx);
return ret;
}
+
+errno_t string_to_shadowpw_days(const char *s, long *d)
+{
+ long l;
+ char *endptr;
+
+ if (s == NULL || *s == '\0') {
+ *d = -1;
+ return EOK;
+ }
+
+ errno = 0;
+ l = strtol(s, &endptr, 10);
+ if (errno != 0) {
+ DEBUG(1, ("strtol failed [%d][%s].\n", errno, strerror(errno)));
+ return errno;
+ }
+
+ if (*endptr != '\0') {
+ DEBUG(1, ("Input string [%s] is invalid.\n", s));
+ return EINVAL;
+ }
+
+ if (*d < -1) {
+ DEBUG(1, ("Input string contains not allowed negative value [%d].\n",
+ *d));
+ return EINVAL;
+ }
+
+ *d = l;
+
+ return EOK;
+}
+