diff -Naur dirtbase/define.h dirt-1.0.0a25-source/define.h --- dirtbase/define.h 2006-12-17 04:06:39.000000000 +0100 +++ dirt-1.0.0a25-source/define.h 2007-10-19 11:37:39.000000000 +0200 @@ -2,7 +2,7 @@ #define DEFINE_H #define APPNAME "Dirt" -#define APPVERSION "1.0.0 alpha 25" +#define APPVERSION "1.0.0 alpha 25 (extended)" #define APPAUTHOR "TmowhrekF" #define APPMAIL "tmowhrekf@filosoferna.se" #define APPURL "http://dirtirc.sf.net/" diff -Naur dirtbase/proxy.cpp dirt-1.0.0a25-source/proxy.cpp --- dirtbase/proxy.cpp 2006-12-17 03:55:13.000000000 +0100 +++ dirt-1.0.0a25-source/proxy.cpp 2007-10-19 11:01:58.000000000 +0200 @@ -149,7 +149,36 @@ } } cmd = uppercase(pop_word_front(args)); - if (cmd == "PRIVMSG" || cmd == "NOTICE") { + + if(cmd == "332" || cmd == "TOPIC") { + string topic_command = line; + string target_user = ""; + + if(cmd == "332") + target_user = pop_word_front(args); + + string channel = pop_word_front(args); + string::size_type idx = args.find_first_of(":"); + if(idx != 0xffffffff) { + string topic = args.substr(idx + 1), topic_decoded; + string keyname; + + if(channel[0] == '#' || target[0] == '&') + keyname = channel; + else + keyname = source; + + key::decode(keyname, topic, topic_decoded); + + topic_command = prefix + " " + cmd + " " + target_user + " " + channel + " :" + topic_decoded; + if(topic_command[0] != ':') + topic_command.insert(0, ":"); + } + + user.putline(topic_command); + return; + } + else if (cmd == "PRIVMSG" || cmd == "NOTICE") { target = pop_word_front(args); if (target.empty()) return; if (args.substr(0, 1) == ":") args.erase(0, 1); @@ -249,6 +278,16 @@ if (cmd == "PRIVMSG" || cmd == "NOTICE") { string target = pop_word_front(args); message(prefix, cmd, target, args); + } else if (cmd == "TOPIC") { + string topic_encoded; + string target = pop_word_front(args); + + if(args.substr(0, 1) == ":") + args = args.erase(0, 1); + + key::encode(target, args, topic_encoded); + string buf = "TOPIC " + target + " :" + topic_encoded; + irc.putline(buf); } else if (cmd == "DIRT") { string dirtcmd = pop_word_front(args); dirt(dirtcmd, args); diff -Naur dirtbase/unix.cpp dirt-1.0.0a25-source/unix.cpp --- dirtbase/unix.cpp 2006-12-05 04:08:32.000000000 +0100 +++ dirt-1.0.0a25-source/unix.cpp 2007-10-19 11:47:46.000000000 +0200 @@ -9,6 +9,8 @@ #include #include #include +#include +#include using namespace std; @@ -79,6 +81,8 @@ cout << " -v, --version show version information" << endl; cout << " -b, --background start as a daemon (default)" << endl; cout << " -f, --foreground start as a normal user process" << endl; + cout << " -u , --user start as user X" << endl; + cout << " -g , --group start as group X" << endl; cout << " -q, --quit quit daemon" << endl; exit(0); } else if (s == "-v" || s == "--version") { @@ -94,6 +98,29 @@ config.reset(); config.save(); exit(0); + } else if(s == "-u" || s == "--user") { + string arg; + passwd *pwd; + + arg = pop_word_front(cmdline); + if(arg.length() == 0) platform::error("Invalid argument to -u option."); + + pwd = getpwnam(arg.c_str()); + if(pwd == NULL) platform::error("Invalid username specified."); + + if(setuid(pwd->pw_uid) != 0) + platform::error("No permissions to change user."); + } else if(s == "-g" || s == "--group") { + string arg; + group *grp; + arg = pop_word_front(cmdline); + if(arg.length() == 0) platform::error("Invalid argument to -g option."); + + grp = getgrnam(arg.c_str()); + if(grp == NULL) platform::error("Invalid group specified."); + + if(setgid(grp->gr_gid) != 0) + platform::error("No permissions to change group."); } else { platform::error("Unrecognized option `" + s + "'\nTry `" + unixname + " --help' for more information."); } @@ -135,9 +162,9 @@ string homedir() { - const char *homedir; - homedir = getenv("HOME"); - if (homedir) return homedir; + //const char *homedir; + //homedir = getenv("HOME"); + //if (homedir) return homedir; struct passwd *pwd = getpwuid(getuid()); if (pwd) return pwd->pw_dir; return ""; @@ -188,17 +215,18 @@ int main(int argc, char **args) { - set_umask(); - get_workdir(); - get_confdir(); - if (!set_rc_dir()) platform::error((string)"Could not change directory to ~/" + rc_dir); string s; int i; for (i = 0; i < argc - 1; i++) { if (i > 0) s += " "; s += args[i + 1]; } + interpret_cmdline(s, args[0]); + set_umask(); + get_workdir(); + get_confdir(); + if (!set_rc_dir()) platform::error((string)"Could not change directory to ~/" + rc_dir); pid_t pid = 0; ifstream pidfile(PIDFILE, ios::in); if (pidfile.good()) {