This file is indexed.

/usr/lib/sbnc/scripts/lock.tcl is in sbnc-tcl 1.2-25.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
internalbind command lock:command

set ::globallocks [list awaymessage]

proc lock:command {client parameters} { 
	set command [lindex $parameters 0]
	
	if {[string equal -nocase $command "help"] && [getbncuser $client admin]} {
		bncaddcommand lock Admin "locks a user's settings" "/sbnc lock <user> \[setting\]\nShows locked settings for a user or locks a setting"
		bncaddcommand unlock Admin "unlocks a user's settings" "/sbnc unlock <user> <setting>\nUnlocks a users setting"
	}
	
	if {[string equal -nocase $command "lock"]} {
		if {[getbncuser $client admin]} {
			if {[llength $parameters] <= 1} {
				bncreply "Syntax: /sbnc lock <user> \[setting\]"
				haltoutput
			} else {
				if {[string equal -nocase [lindex $parameters 2] ""]} {
					set tmp [split [bncuserlist] " "]
					set res [lsearch $tmp [lindex $parameters 1]]
					if {[string equal -nocase $res "-1"]} {
						bncreply "No such user [lindex $parameters 1]."
						haltoutput
					} else {			 
						set tmp [split [getbncuser [lindex $parameters 1] tag locksetting] ","]
						bncreply "Locked settings for user [lindex $parameters 1]:"
						if {[string equal -nocase $tmp ""]} {
							bncreply "None."
							haltoutput	
						} else {
							bncreply $tmp
							haltoutput
						}
					}
				} else {
					if {[lsearch -exact [list server port realname awaynick away awaymessage vhost quitasaway] [lindex $parameters 2]] == -1} {
						bncreply "Error: Cannot lock this setting."
						haltoutput
					} else {
						set tmp [split [getbncuser [lindex $parameters 1] tag locksetting] ","]
						lappend tmp [lindex $parameters 2]
						setbncuser [lindex $parameters 1] tag locksetting [join $tmp ","]
						bncreply "Done."
						haltoutput
					}
				}
			}
		}
	}

	if {[string equal -nocase $command "unlock"]} {
		if {[getbncuser $client admin]} {
			if {[llength $parameters] < 3} {
				bncreply "Syntax: /sbnc unlock <user> <setting>"
				haltoutput
			} else {
				set tmp [split [bncuserlist] " "]
				set res [lsearch $tmp [lindex $parameters 1]]
				if {[string equal -nocase $res "-1"]} {
					bncreply "No such user [lindex $parameters 1]."
					haltoutput
				} else {
					set tmp [split [getbncuser [lindex $parameters 1] tag locksetting] ","];
					set idx [lsearch -exact $tmp [lindex $parameters 2]]
					set tmp [lreplace $tmp $idx $idx]
					setbncuser [lindex $parameters 1] tag locksetting [join $tmp ","]
					bncreply "Done."
					haltoutput
				}
			}
		}
	}

	if {[string equal -nocase $command "set"] && [llength $parameters] > 2} {
		set setting [lindex $parameters 1]
		set notlocked [lock:set $client $setting [join [lrange $parameters 2 end]]]

		if {[string equal -nocase $setting "server"] && $notlocked} {
			set notlocked [lock:set $client "port" [join [lrange $parameters 2 end]]]
		}

		if {$notlocked} {
			return
		} else {
			bncreply "Error: You cannot modify this setting."
			haltoutput
		}
	}
	
}

#------------------ HALT SET WHEN LOCKED --------------------
proc lock:ifacecmd {command params account override} {
	switch -- $command {
		"lockedsetting" {
			return [lock:islocked $account [lindex $params 0]]
		}
		"set" {
			if {$override || [lock:set $account [lindex $params 0] [lrange $params 1 end]]} {
				return
			} else {
				return "denied."
			}
		}
	}
	
	if {[getbncuser $account admin]} {
		switch -- $command {
			"locksetting" {
				set tmp [split [getbncuser [lindex $params 0] tag locksetting] ","]
				set res [lsearch -exact $tmp [lindex $params 1]]

				if {[string equal -nocase $res "-1"]} {
					lappend tmp [lindex $params 1]
				}
				setbncuser [lindex $params 0] tag locksetting [join $tmp ","]
			}	
			"unlocksetting" {
				set tmp [split [getbncuser [lindex $params 0] tag locksetting] ","]; 
				set idx [lsearch -exact $tmp [lindex $params 1]]
				set tmp [lreplace $tmp $idx $idx]
				setbncuser [lindex $params 0] tag locksetting [join $tmp ","] 
			}
		}
	}
}

proc lock:islocked {account setting} {
	global globallocks

	set tmp [split [getbncuser $account tag locksetting] ","]

	if {[lsearch -exact $tmp $setting] != -1} {
		return 1
	} else {
		if {[lsearch -exact $globallocks $setting] != -1} {
			return 2
		} else {
			return 0
		}
	}
}

# account = who wants to set
# parameters
#	0 = what user
#	1 = what setting
#	2 - end = value
# returns:
#	1 if user can change the setting
#	0 otherwise
proc lock:set {account setting value} {
	if {[getbncuser $account admin]} {
		return 1
	} else {
		if {![string equal [lock:islocked $account $setting] "0"]} {
			return 0
		} else {
			return 1
		}
	}
}

if {[lsearch -exact [info commands] "registerifacehandler"] != -1} {
	registerifacehandler lock lock:ifacecmd
}