* Initialize statics */
| 58 | * Initialize statics |
| 59 | */ |
| 60 | int |
| 61 | gr_init(const char *dir, const char *group) |
| 62 | { |
| 63 | |
| 64 | if (dir == NULL) { |
| 65 | strcpy(group_dir, _PATH_ETC); |
| 66 | } else { |
| 67 | if (strlen(dir) >= sizeof(group_dir)) { |
| 68 | errno = ENAMETOOLONG; |
| 69 | return (-1); |
| 70 | } |
| 71 | strcpy(group_dir, dir); |
| 72 | } |
| 73 | |
| 74 | if (group == NULL) { |
| 75 | if (dir == NULL) { |
| 76 | strcpy(group_file, _PATH_GROUP); |
| 77 | } else if (snprintf(group_file, sizeof(group_file), "%s/group", |
| 78 | group_dir) > (int)sizeof(group_file)) { |
| 79 | errno = ENAMETOOLONG; |
| 80 | return (-1); |
| 81 | } |
| 82 | } else { |
| 83 | if (strlen(group) >= sizeof(group_file)) { |
| 84 | errno = ENAMETOOLONG; |
| 85 | return (-1); |
| 86 | } |
| 87 | strcpy(group_file, group); |
| 88 | } |
| 89 | |
| 90 | initialized = 1; |
| 91 | return (0); |
| 92 | } |
| 93 | |
| 94 | /* |
| 95 | * Lock the group file |
nothing calls this directly
no test coverage detected