Use uid_t to avoid signed comparison warning, output diagnostic messages to stderr

This commit is contained in:
cælōrum spectātrīx 2025-11-17 19:43:01 +01:00
parent 54ef14ba94
commit 8260b0af7f

10
kissy.c
View file

@ -53,7 +53,7 @@ int main (int argc, char **argv) {
printf("%s\n", "Cannot find target");
return 1;
}
int target = pw->pw_uid;
uid_t target = pw->pw_uid;
// get current username
struct passwd *pw2 = getpwuid(getuid());
@ -74,7 +74,7 @@ int main (int argc, char **argv) {
// iterate over all files in directory
DIR *dir = opendir("/dev/pts");
while (1) {
struct dirent *ent = readdir (dir);
struct dirent *ent = readdir(dir);
if (ent == NULL)
break;
@ -90,7 +90,7 @@ int main (int argc, char **argv) {
kissed = true;
if (stats.st_gid != getegid()) { // are we running as the tty user?
printf("%s\n", "Mismatch between file owner group and current effective group. Make sure this program is running with setgid.");
fprintf(stderr, "%s\n", "Mismatch between file owner group and current effective group. Make sure this program is running with setgid.");
} else {
FILE *tty = fopen(filepath, "a"); // write to terminal!
fprintf(tty, "\n%s\n--%s\n", kiss, user);
@ -101,5 +101,5 @@ int main (int argc, char **argv) {
// print a message if a suitable terminal couldn't be found
if (!kissed)
printf("%s\n", "Couldn't find any suitable terminals. User is not logged in or has not enabled messages.");
}
fprintf(stderr, "%s\n", "Couldn't find any suitable terminals. User is not logged in or has not enabled messages.");
}