#define __OWN_USERDB_PARSER__
#endif
+#ifdef __GLIBC__
+#define __OWN_STRLCPYCAT__
+#endif
+
#ifdef USE_STATIC
#define __OWN_USERDB_PARSER__
#endif
-#ifndef strlcpy
+#ifdef __OWN_STRLCPYCAT__
size_t strlcpy(char *dst, const char *src, size_t size)
{
size_t bytes = 0;
char ch;
while ((ch = *p++)) {
- if (bytes < size)
+ if (bytes+1 < size)
*q++ = ch;
bytes++;
}
- *q = '\0';
+ /* If size == 0 there is no space for a final null... */
+ if (size)
+ *q = '\0';
+
return bytes;
}
-#endif
-#ifndef strlcat
size_t strlcat(char *dst, const char *src, size_t size)
{
size_t bytes = 0;
q++;
bytes++;
}
+ if (bytes == size)
+ return (bytes + strlen(src));
while ((ch = *p++)) {
- if (bytes < size)
+ if (bytes+1 < size)
*q++ = ch;
bytes++;
}
*q = '\0';
return bytes;
}
-#endif
+#endif /* __OWN_STRLCPYCAT__ */
#ifndef __OWN_USERDB_PARSER__
#include <sys/types.h>
pw = getpwnam(user);
if (pw == NULL)
- dbg("specified user unknown '%s'", user);
+ info("specified user unknown '%s'", user);
else
uid = pw->pw_uid;
gr = getgrnam(group);
if (gr == NULL)
- dbg("specified group unknown '%s'", group);
+ info("specified group unknown '%s'", group);
else
gid = gr->gr_gid;
char *tail;
if (file_map(dbfile, &buf, &bufsize) != 0) {
- dbg("can't open '%s' as db file", dbfile);
+ err("can't open '%s' as db file: %s", dbfile, strerror(errno));
return 0;
}
- dbg("reading '%s' as db file", dbfile);
+ dbg("search '%s' in '%s'", uname, dbfile);
/* loop through the whole file */
cur = 0;
if (count >= sizeof(line))
continue;
- strlcpy(line, bufline, count);
+ memcpy(line, bufline, count-1);
+ line[count-1] = '\0';
pos = line;
/* get name */