You can now do --help and -h. also they work better yay
This commit is contained in:
parent
be7550436f
commit
419859a366
1 changed files with 14 additions and 21 deletions
35
kissy.c
35
kissy.c
|
|
@ -1,4 +1,4 @@
|
|||
// KISSY (Kissing Interface for Sapphic Smooching over ttY) v1.0
|
||||
// KISSY (Kissing Interface for Sapphic Smooching over ttY) v1.1
|
||||
|
||||
/*
|
||||
Copyright (C) 2025 Magdalunaa <magdalunaa@linuxposting.xyz>
|
||||
|
|
@ -17,17 +17,6 @@
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file needs to:
|
||||
- be owned by the tty group (or whatever group owns the terminal devices in your system)
|
||||
- have setgid set
|
||||
- be group executable
|
||||
- not be world writeable
|
||||
|
||||
You can probably just use 2755 permissions. those work
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
|
@ -35,25 +24,29 @@ You can probably just use 2755 permissions. those work
|
|||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// mreowww meow nya :3
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
// print help
|
||||
if (argc < 2 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) {
|
||||
printf("%s\n", "Usage: kissy [target] <message>\n\n"
|
||||
"Kissy is a utility that allows you to kiss currently logged in users who allow messages.\n"
|
||||
"It works by writing to files in /dev/pts. It needs to run as the group who owns said files (usually tty), using setgid (2755 permissions).");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// are we running with setgid?
|
||||
struct stat stat_self;
|
||||
stat("/proc/self/exe", &stat_self);
|
||||
|
||||
if (!(stat_self.st_mode & S_ISGID && !(stat_self.st_mode & S_IWOTH))) {
|
||||
printf("%s\n", "setgid is not set, or this file is world writeable.");
|
||||
printf("%s\n", "setgid is not set, or this file is world writable.");
|
||||
return 3;
|
||||
}
|
||||
|
||||
// check we have at least one argument
|
||||
if (argc < 2) {
|
||||
printf("%s\n", "Not enough arguments!\nUsage: kissy [target] <message>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// try to find the target's uid
|
||||
struct passwd *pw = getpwnam(argv[1]);
|
||||
if (pw == NULL) {
|
||||
|
|
@ -77,7 +70,7 @@ int main (int argc, char **argv) {
|
|||
else
|
||||
kiss = "*mwah*";
|
||||
|
||||
short kissed = 0;
|
||||
bool kissed = false;
|
||||
// iterate over all files in directory
|
||||
DIR *dir = opendir("/dev/pts");
|
||||
while (1) {
|
||||
|
|
@ -94,7 +87,7 @@ int main (int argc, char **argv) {
|
|||
|
||||
// find all terminals with the correct user and that are group-writable
|
||||
if (stats.st_mode & S_IWGRP && stats.st_uid == target) {
|
||||
kissed = 1;
|
||||
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.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue