On Thu, Dec 20, 2018 at 09:02:24AM +0100, Tomas Mraz wrote:
The attached patch cleans up some issues introduced in pam_motd by
the
recent Github pull request. I made the mistake that I did not build it
before merging and I did not catch these issues in the review.
In particular it fixes warnings about int signedness, about losing
const qualifier and unused function.
It also silences syslog error reporting if in the default configuration
the motd directories are missing. I keep the error log in case the
configuration is non-default or the error is something else than
ENOENT.
OK to commit?
Thanks, it looks good although I haven't tried to compile it, too.
Just two minor issues you can try to address while committing:
@@ -226,17 +205,20 @@ static void
try_to_display_directories_with_overrides(pam_handle_t *pamh,
pam_syslog(pamh, LOG_CRIT, "pam_motd: failed to allocate dirent arrays");
goto out;
}
- if ((dirscans_sizes = (int *)calloc(num_motd_dirs, sizeof(int))) == NULL) {
+ if ((dirscans_sizes = (unsigned int *)calloc(num_motd_dirs, sizeof(int))) == NULL) {
I don't think any cast of calloc return value is needed.
pam_syslog(pamh, LOG_CRIT, "pam_motd: failed to allocate
dirent array sizes");
goto out;
}
for (i = 0; i < num_motd_dirs; i++) {
- dirscans_sizes[i] = scandir(motd_dir_path_split[i], &(dirscans[i]),
+ int rv;
+ rv = scandir(motd_dir_path_split[i], &(dirscans[i]),
filter_dirents, alphasort);
- if (dirscans_sizes[i] < 0) {
- pam_syslog(pamh, LOG_ERR, "pam_motd: error scanning directory %s",
motd_dir_path_split[i]);
- dirscans_sizes[i] = 0;
+ if (rv < 0) {
+ if (errno != ENOENT || report_missing) {
+ pam_syslog(pamh, LOG_ERR, "pam_motd: error scanning directory %s: %m",
motd_dir_path_split[i]);
This line was too long before the change, could you wrap it, please?
--
ldv