Hi Akos,
I know that you might not agree with me, but I've changed the way how
brag get it user name and password, which was described in the feature
request.
I'm submitting the patch. You can decide to take it or not. The benefit
would be:
1st consistency: If one can access three news servers, the first one does
not require user name/password, the latter two do, but the user id is
different. In the original approach, they have to change the script in
order to change the news server (need three different scripts for three
different news servers). In current approach, just alter the
environment variable NNTPSERVER will do, no need to change the script
any more.
2nd minimum disclosure: If one has a bunch of news servers which require
user name/password, it is not necessary to store the news server B's
user name/password under news server A's password file.
Hope that I've made myself clear enough. Again, it's up to you to take
it or not.
Tong
--- /usr/bin/brag.031112 2003-11-12 08:27:20.000000000 -0500
+++ /usr/bin/brag.031117 2003-11-17 11:30:58.000000000 -0500
@@ -550,26 +550,23 @@
}
set serverDir [getServerDir]
- # Get password from passwd file, if not specified on the command line
+ # Get user/password from passwd file, if there is one
- if {[info exists user]} {
- if {![info exists password]} {
+ set passwdFile [file join [getServerDir] passwd]
+ if {[file exist $passwdFile]} {
catch {
- set fh [open [file join [getServerDir] "passwd"]]
- foreach line [split [read $fh] "\n"] {
- if {[string match "${user}:*" $line]} {
- regsub -- "^${user}:" $line "" password
- break
- }
+ set fh [open $passwdFile]
+ set line [read $fh]
+ set cmd ''
+ regsub -- "^(.*):(.*)" $line {set user \1; set password \2} cmd
+ eval $cmd
}
close $fh
- }
if {![info exists password]} {
- puts stderr "brag: No password for user \"$user\""
+ puts stderr "brag: No user/password pair found in $passwdFile."
exit 1
}
}
- }
if {![info exists lflag]} {
# Set the group if not present on the command line.
against v 1.41 2003/11/12