1 diff -burN eggdrop1.6.17.orig/doc/tcl-commands.doc eggdrop1.6.17/doc/tcl-commands.doc
2 --- eggdrop1.6.17.orig/doc/tcl-commands.doc 2004-11-01 12:48:53.000000000 +0100
3 +++ eggdrop1.6.17/doc/tcl-commands.doc 2004-11-01 14:21:10.565861080 +0100
9 +***### SHARE MODULE COMMANDS ###***
11 + noshare <command> [<arg1> <arg2> ...]
12 + Description: executes command with setting noshare = 1 in code,
13 + that means, if you i.e. do chattr using this command,
14 + bot will make changes on his userlist, but won't send changes
15 + to other bots. This is useful in some situations.
16 + Returns: whatever is returned by <command>
19 *** MISCELLANEOUS COMMANDS ***
21 bind <type> <flags> <keyword/mask> [proc-name]
22 diff -burN eggdrop1.6.17.orig/doc/USERS eggdrop1.6.17/doc/USERS
23 --- eggdrop1.6.17.orig/doc/USERS 2004-11-01 12:48:53.000000000 +0100
24 +++ eggdrop1.6.17/doc/USERS 2004-11-01 14:21:10.567860776 +0100
27 u (unshared) user record is not sent to other bots.
29 + s (protected) is working similar like u flag, but changes can be made
30 + only from bot that is aggressively sharing with us (Hub).
31 + User cannot be changed by bot that is connected below
32 + this bot. (This flag can be useful in multilevel sharing)
34 h (highlight) use bold text in help/text files.
36 All global flags other then u, h, b, c, x, j, and p are also
37 diff -burN eggdrop1.6.17.orig/eggdrop.conf eggdrop1.6.17/eggdrop.conf
38 --- eggdrop1.6.17.orig/eggdrop.conf 2004-11-01 12:48:53.000000000 +0100
39 +++ eggdrop1.6.17/eggdrop.conf 2004-11-01 14:21:10.570860320 +0100
40 @@ -1145,11 +1145,21 @@
41 # changes from other bots should be ignored?
42 #set private-globals "mnot"
44 +# When sharing user lists, which channel flags changes from other bots
46 +#set private-chanflags "mn"
48 # When sharing user lists, don't accept ANY userfile changes from other
49 # bots? Paranoid people should use this feature on their hub bot. This
50 # will force all userlist changes to be made via the hub.
53 +# When you have multilevel botnet, this option permits hub, to make changes,
54 +# even when private-global, private-chanflags and/or private-user are set.
55 +# NOTE: this option doesn't permit hub to force flags filtered by
59 # This setting makes the bot discard its own bot records in favor of
60 # the ones sent by the hub.
61 # NOTE: No passwords or botflags are shared, only ports and
62 diff -burN eggdrop1.6.17.orig/help/cmds2.help eggdrop1.6.17/help/cmds2.help
63 --- eggdrop1.6.17.orig/help/cmds2.help 2004-11-01 12:48:53.000000000 +0100
64 +++ eggdrop1.6.17/help/cmds2.help 2004-11-01 14:21:10.572860016 +0100
66 %bp%b - party-line (user has access to the partyline)
67 %bq%b - quiet (user cannot gain voice on any channel)
68 %br%b - dehalfop (user cannot gain halfops on any channel)
69 + %bs%b - protected (when sharing changes can be made only by hub)
70 %bt%b - botnet master (user has access to features related to the botnet)
71 %bu%b - unshared (user's user record is not sent to other bots)
72 %bv%b - voice (user gets +v automatically on +autovoice channels)
73 diff -burN eggdrop1.6.17.orig/src/cmds.c eggdrop1.6.17/src/cmds.c
74 --- eggdrop1.6.17.orig/src/cmds.c 2004-11-01 12:48:53.000000000 +0100
75 +++ eggdrop1.6.17/src/cmds.c 2004-11-01 14:21:10.576859408 +0100
77 mns.chan &= ~(BOT_SHARE);
79 if (!glob_owner(user)) {
80 - pls.global &=~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
81 - mns.global &=~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
82 + pls.global &=~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED | USER_PROTECTED);
83 + mns.global &=~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED | USER_PROTECTED);
86 pls.chan &= ~USER_OWNER;
87 diff -burN eggdrop1.6.17.orig/src/flags.h eggdrop1.6.17/src/flags.h
88 --- eggdrop1.6.17.orig/src/flags.h 2004-11-01 12:48:53.000000000 +0100
89 +++ eggdrop1.6.17/src/flags.h 2004-11-01 14:21:10.577859256 +0100
94 - * abcdefgh?jklmnopqr?tuvwxyz + user defined A-Z
95 - * unused letters: is
96 + * abcdefgh?jklmnopqrstuvwxyz + user defined A-Z
100 * 0123456789ab????ghi??l???p?rs???????
102 * a??defg???klmno?qr??uv??yz + user defined A-Z
103 * unused letters: bchijpstwx
105 -#define USER_VALID 0x03fbfeff /* Sum of all USER_ flags */
106 +#define USER_VALID 0x03fffeff /* Sum of all USER_ flags */
107 #define CHAN_VALID 0x03777c79 /* Sum of all CHAN_ flags */
108 #define BOT_VALID 0x7fe689C1 /* Sum of all BOT_ flags */
111 #define USER_PARTY 0x00008000 /* p user has party line access */
112 #define USER_QUIET 0x00010000 /* q user is global de-voice */
113 #define USER_DEHALFOP 0x00020000 /* r user is global de-halfop */
114 -#define USER_S 0x00040000 /* s unused */
115 +#define USER_PROTECTED 0x00040000 /* s user is protected (cannot be removed/changed by downlinks */
116 #define USER_BOTMAST 0x00080000 /* t user is botnet master */
117 #define USER_UNSHARED 0x00100000 /* u not shared with sharebots */
118 #define USER_VOICE 0x00200000 /* v user is +v on all channels */
120 #define glob_hilite(x) ((x).global & USER_HIGHLITE)
121 #define chan_exempt(x) ((x).chan & USER_EXEMPT)
122 #define glob_exempt(x) ((x).global & USER_EXEMPT)
123 +#define glob_protected(x) ((x).global & USER_PROTECTED)
125 #define bot_global(x) ((x).bot & BOT_GLOBAL)
126 #define bot_chan(x) ((x).chan & BOT_AGGRESSIVE)
127 diff -burN eggdrop1.6.17.orig/src/mod/share.mod/share.c eggdrop1.6.17/src/mod/share.mod/share.c
128 --- eggdrop1.6.17.orig/src/mod/share.mod/share.c 2004-11-01 12:48:53.000000000 +0100
129 +++ eggdrop1.6.17/src/mod/share.mod/share.c 2004-11-01 14:27:44.822924896 +0100
131 static int private_global = 0;
132 static int private_user = 0;
133 static char private_globals[50];
134 +static char private_chanflags[50];
135 static int allow_resync = 0;
136 static struct flag_record fr = { 0, 0, 0, 0, 0, 0 };
137 static int resync_time = 900;
138 static int overr_local_bots = 0; /* Override local bots? */
140 +static int permit_hub = 0; /* Permit hub to do changes even, when we use private_*, */
141 + /* but not private_globals (this have a reason) */
143 /* Store info for sharebots */
146 static void q_resync(char *, struct chanset_t *);
147 static void cancel_user_xfer(int, void *);
148 static int private_globals_bitmask();
149 +static int private_chanflags_bitmask();
157 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
158 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
159 hand = newsplit(&par);
160 u = get_user_by_handle(userlist, hand);
161 if (u && !(u->flags & USER_UNSHARED)) {
162 @@ -336,26 +340,33 @@
166 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
167 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
168 hand = newsplit(&par);
169 u = get_user_by_handle(userlist, hand);
170 - if (u && !(u->flags & USER_UNSHARED)) {
171 + if (u && !(u->flags & USER_UNSHARED) && !IS_USER_PROTECTED(u, idx)) {
172 atr = newsplit(&par);
173 cst = findchan_by_dname(par);
174 if (!par[0] || (cst && channel_shared(cst))) {
175 - if (!(dcc[idx].status & STAT_GETTING) && (cst || !private_global))
176 - shareout_but(cst, idx, "a %s %s %s\n", hand, atr, par);
180 + if (!PERMIT_HUB(idx))
181 + pchbm = private_chanflags_bitmask();
182 fr.match = (FR_CHAN | FR_BOT);
183 + /* bot's sharing flags */
184 get_user_flagrec(dcc[idx].user, &fr, par);
185 if (bot_chan(fr) || bot_global(fr)) {
188 break_down_flags(atr, &fr, 0);
189 get_user_flagrec(u, &fr2, par);
190 - fr.chan = (fr2.chan & BOT_AGGRESSIVE) |
191 - (fr.chan & ~BOT_AGGRESSIVE);
192 + fr.chan = (fr2.chan & BOT_AGGRESSIVE) | (fr.chan & ~BOT_AGGRESSIVE);
193 + /* Checking for forced flags */
194 + if ( (pchbm & USER_OWNER) && chan_owner(fr) && !chan_owner(fr2))
195 + fr.chan &= ~(USER_MASTER | USER_OP);
196 + else if ( (pchbm & USER_MASTER) && chan_master(fr) && !chan_master(fr2))
197 + fr.chan &= ~USER_OP;
198 + fr.chan = (fr2.chan & pchbm) | (fr.chan & ~pchbm);
199 set_user_flagrec(u, &fr, par);
200 check_dcc_chanattrs(u, par, fr.chan, fr2.chan);
203 putlog(LOG_CMDS, "*",
204 "Rejected flags for unshared channel %s from %s",
206 - } else if (!private_global) {
207 + } else if (!private_global || PERMIT_HUB(idx)) {
208 int pgbm = private_globals_bitmask();
210 /* Don't let bot flags be altered */
211 @@ -391,15 +402,18 @@
212 if (!(dcc[idx].status & STAT_GETTING))
213 putlog(LOG_CMDS, "*", "%s: chattr %s %s", dcc[idx].nick, hand, s);
214 if ((me = module_find("irc", 0, 0))) {
215 + struct chanset_t *tmpcst;
216 Function *func = me->funcs;
218 - for (cst = chanset; cst; cst = cst->next)
219 - (func[IRC_RECHECK_CHANNEL]) (cst, 0);
220 + for (tmpcst = chanset; tmpcst; tmpcst = tmpcst->next)
221 + (func[IRC_RECHECK_CHANNEL]) (tmpcst, 0);
224 putlog(LOG_CMDS, "*", "Rejected global flags for %s from %s",
225 hand, dcc[idx].nick);
227 + if (!(dcc[idx].status & STAT_GETTING) && (cst || !private_global || PERMIT_HUB(idx)))
228 + shareout_but(cst, idx, "a %s %s %s\n", hand, s, par);
233 struct chanset_t *chan;
236 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
237 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
238 user = newsplit(&par);
239 if ((u = get_user_by_handle(userlist, user))) {
240 chan = findchan_by_dname(par);
242 struct chanset_t *chan;
245 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
246 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
247 user = newsplit(&par);
248 if ((u = get_user_by_handle(userlist, user))) {
249 chan = findchan_by_dname(par);
250 @@ -466,13 +480,13 @@
251 char *nick, *host, *pass, s[100];
254 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
255 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
256 nick = newsplit(&par);
257 host = newsplit(&par);
258 pass = newsplit(&par);
260 if (!(u = get_user_by_handle(userlist, nick)) ||
261 - !(u->flags & USER_UNSHARED)) {
262 + !((u->flags & USER_UNSHARED) || IS_USER_PROTECTED(u, idx))) {
265 fr.match = FR_GLOBAL;
269 /* If user is a share bot, ignore command */
270 - if ((dcc[idx].status & STAT_SHARE) && !private_user &&
271 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx)) &&
272 (u = get_user_by_handle(userlist, par)) &&
273 - !(u->flags & USER_UNSHARED) &&
274 + !(u->flags & USER_UNSHARED) && !IS_USER_PROTECTED(u, idx) &&
275 !((u->flags & USER_BOT) && (bot_flags(u) & BOT_SHARE))) {
278 @@ -535,10 +549,10 @@
282 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
283 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
284 hand = newsplit(&par);
285 if ((u = get_user_by_handle(userlist, hand)) &&
286 - !(u->flags & USER_UNSHARED)) {
287 + !(u->flags & USER_UNSHARED) && !IS_USER_PROTECTED(u, idx)) {
288 shareout_but(NULL, idx, "+h %s %s\n", hand, par);
289 set_user(&USERENTRY_HOSTS, u, par);
290 putlog(LOG_CMDS, "*", "%s: +host %s %s", dcc[idx].nick, hand, par);
291 @@ -551,10 +565,10 @@
295 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
296 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
297 hand = newsplit(&par);
298 if (!(u = get_user_by_handle(userlist, hand)) ||
299 - !(u->flags & USER_UNSHARED)) {
300 + !((u->flags & USER_UNSHARED) || IS_USER_PROTECTED(u, idx))) {
301 if (!(dcc[idx].status & STAT_GETTING))
302 shareout_but(NULL, idx, "+bh %s %s\n", hand, par);
303 /* Add bot to userlist if not there */
304 @@ -577,10 +591,10 @@
308 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
309 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
310 hand = newsplit(&par);
311 if ((u = get_user_by_handle(userlist, hand)) &&
312 - !(u->flags & USER_UNSHARED)) {
313 + !(u->flags & USER_UNSHARED) && !IS_USER_PROTECTED(u, idx)) {
314 shareout_but(NULL, idx, "-h %s %s\n", hand, par);
316 delhost_by_handle(hand, par);
317 @@ -597,11 +611,11 @@
318 struct user_entry_type *uet;
319 struct user_entry *e;
321 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
322 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
323 key = newsplit(&par);
324 hand = newsplit(&par);
325 if (!(u = get_user_by_handle(userlist, hand)) ||
326 - !(u->flags & USER_UNSHARED)) {
327 + !((u->flags & USER_UNSHARED) || IS_USER_PROTECTED(u,idx))) {
328 if (!(uet = find_entry_type(key)))
329 /* If it's not a supported type, forget it */
330 debug2("Ignore ch %s from %s (unknown type)", key, dcc[idx].nick);
331 @@ -645,10 +659,10 @@
332 struct chanset_t *cst;
335 - if ((dcc[idx].status & STAT_SHARE) && !private_user) {
336 + if ((dcc[idx].status & STAT_SHARE) && (!private_user || PERMIT_HUB(idx))) {
337 hand = newsplit(&par);
338 if ((u = get_user_by_handle(userlist, hand)) &&
339 - !(u->flags & USER_UNSHARED) && share_greet) {
340 + !(u->flags & USER_UNSHARED) && !IS_USER_PROTECTED(u, idx) && share_greet) {
341 chan = newsplit(&par);
342 cst = findchan_by_dname(chan);
343 fr.match = (FR_CHAN | FR_BOT);
344 @@ -2039,11 +2053,13 @@
345 {"private-global", &private_global},
346 {"private-user", &private_user},
347 {"override-bots", &overr_local_bots},
348 + {"permit-hub", &permit_hub},
352 static tcl_strings my_strings[] = {
353 {"private-globals", private_globals, 50, 0},
354 + {"private-chanflags", private_chanflags, 50, 0},
358 @@ -2062,6 +2078,38 @@
359 {NULL, NULL, NULL, NULL}
362 +static int tcl_noshare STDVAR
368 + Tcl_AppendResult(irp, "wrong # args: should be \"",
369 + argv[0], " arg ?arg ...?\"", NULL);
377 + x = Tcl_Merge(argc - 1, argv + 1);
378 + res = Tcl_Eval(irp, x);
379 + Tcl_Free((char *) x);
388 +static tcl_cmds my_tclcmds[] =
390 + {"noshare", tcl_noshare},
394 static char *share_close()
397 @@ -2094,6 +2142,7 @@
399 rem_tcl_ints(my_ints);
400 rem_tcl_strings(my_strings);
401 + rem_tcl_commands(my_tclcmds);
402 rem_builtins(H_dcc, my_cmds);
403 rem_help_reference("share.help");
405 @@ -2213,6 +2262,7 @@
406 DCC_BOT.kill = cancel_user_xfer;
407 add_tcl_ints(my_ints);
408 add_tcl_strings(my_strings);
409 + add_tcl_commands(my_tclcmds);
410 add_builtins(H_dcc, my_cmds);
412 uff_addtable(internal_uff_table);
413 @@ -2226,3 +2276,11 @@
414 break_down_flags(private_globals, &fr, 0);
418 +int private_chanflags_bitmask()
420 + struct flag_record fr = {FR_CHAN, 0, 0, 0, 0, 0};
422 + break_down_flags(private_chanflags, &fr, 0);
425 diff -burN eggdrop1.6.17.orig/src/mod/share.mod/share.h eggdrop1.6.17/src/mod/share.mod/share.h
426 --- eggdrop1.6.17.orig/src/mod/share.mod/share.h 2004-11-01 12:48:53.000000000 +0100
427 +++ eggdrop1.6.17/src/mod/share.mod/share.h 2004-11-01 14:21:10.583858344 +0100
432 +/* Do we allow hub to change user value <TaKeDa> */
433 +#define PERMIT_HUB(x) (permit_hub && (dcc[x].status & STAT_AGGRESSIVE))
434 +/* Is user protected and if he is do we allow changes? <TaKeDa> */
435 +#define IS_USER_PROTECTED(user,idx) (!(dcc[idx].status & STAT_AGGRESSIVE) && (user->flags & USER_PROTECTED))
439 #define finish_share ((void (*) (int))share_funcs[4])
440 diff -burN eggdrop1.6.17.orig/src/patch.h eggdrop1.6.17/src/patch.h
441 --- eggdrop1.6.17.orig/src/patch.h 2004-11-01 12:48:53.000000000 +0100
442 +++ eggdrop1.6.17/src/patch.h 2004-11-01 14:21:10.584858192 +0100
447 -/* PATCH GOES HERE */
448 +patch("multilevel_sharing");