Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
2002aea3
Commit
2002aea3
authored
13 years ago
by
mcmlxxix
Browse files
Options
Downloads
Patches
Plain Diff
display usage and errors the same as makeuser.js
parent
7182dbfd
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/allusers.js
+191
-168
191 additions, 168 deletions
exec/allusers.js
exec/slog.js
+9
-5
9 additions, 5 deletions
exec/slog.js
with
200 additions
and
173 deletions
exec/allusers.js
+
191
−
168
View file @
2002aea3
/*
writeln
(
"
\n
ALLUSERS - Bulk User Editor for Synchronet User Database
\n
"
);
* ALLUSERS - Bulk User Editor for Synchronet User Database
*
* usage: jsexec allusers.js [[ARS] [...]] [[/modify] [...]]
*
* where ARS is any valid ARS string
* (see http://www.synchro.net/docs/security.html)
*
* where modify is one of:
* L# change security level to #
* F#[+|-]<flags> add or remove flags from flag set #
* E[+|-]<flags> add or remove exemption flags
* R[+|-]<flags> add or remove restriction flags
*
* examples:
*
* jsexec allusers.js "L30" /FA add 'A' to flag set #1 for all level 30+ users
* jsexec allusers.js /F3-G remove 'G' from flag set #3 for all users
* jsexec allusers.js F2B /E-P remove 'P' exemption for all users with FLAG '2B'
* jsexec allusers.js "60$XA" /R+W add 'W' restriction for all level 60+ users
* with exemption 'A'
*
* NOTE: multi-word ARS strings or ARS strings with special characters
* must be enclosed in "quotes"
*/
(
function
()
{
(
function
()
{
var
error
=
false
;
/* required values for user matching */
/* required values for user matching */
var
match_rules
=
[];
var
match_rules
=
[];
...
@@ -41,6 +18,32 @@
...
@@ -41,6 +18,32 @@
exemptions
:
undefined
exemptions
:
undefined
}
}
/* display command usage */
function
usage
()
{
writeln
(
'
usage: jsexec allusers.js [[ARS] [...]] [[/modify] [...]]
'
);
writeln
();
writeln
(
'
where ARS is any valid ARS string
'
);
writeln
(
'
(see http://www.synchro.net/docs/security.html)
'
);
writeln
();
writeln
(
'
where modify is one of:
'
);
writeln
(
'
L# change security level to #
'
);
writeln
(
'
F#[+|-]<flags> add or remove flags from flag set #
'
);
writeln
(
'
E[+|-]<flags> add or remove exemption flags
'
);
writeln
(
'
R[+|-]<flags> add or remove restriction flags
'
);
writeln
();
writeln
(
'
examples: jsexec allusers.js ..
'
);
writeln
();
writeln
(
'
"L30" /FA add "A" to flag set #1 for all level 30+ users
'
);
writeln
(
'
/F3-G remove "G" from flag set #3 for all users
'
);
writeln
(
'
F2B /E-P remove "P" exemption for all users with FLAG "2B"
'
);
writeln
(
'
"60$XA" /R+W add "W" restriction for all level 60+ users
'
);
writeln
(
'
with exemption "A"
'
);
writeln
();
writeln
(
'
NOTE: multi-word ARS strings or ARS strings with special characters
'
);
writeln
(
'
must be enclosed in "quotes"
'
);
writeln
();
}
/* apply argument to edit rule */
/* apply argument to edit rule */
function
setEditRule
(
str
)
{
function
setEditRule
(
str
)
{
...
@@ -71,14 +74,19 @@
...
@@ -71,14 +74,19 @@
restrictions
=
str
.
substr
(
1
);
restrictions
=
str
.
substr
(
1
);
break
;
break
;
default
:
default
:
throw
(
"
invalid edit rule:
"
+
str
);
writeln
(
"
* Invalid edit rule:
"
+
str
);
error
=
true
;
break
;
break
;
}
}
if
(
level
&&
level
<
1
||
level
>
99
)
if
(
level
&&
level
<
1
||
level
>
99
)
{
throw
(
"
invalid security level:
"
+
level
);
writeln
(
"
* Invalid security level:
"
+
level
);
if
(
flag_set
<
1
||
flag_set
>
4
)
error
=
true
;
throw
(
"
invalid flag set:
"
+
flag_set
);
}
if
(
flag_set
<
1
||
flag_set
>
4
)
{
writeln
(
"
* Invalid flag set:
"
+
flag_set
);
error
=
true
;
}
if
(
level
&&
!
edit_rule
.
level
)
if
(
level
&&
!
edit_rule
.
level
)
edit_rule
.
level
=
level
;
edit_rule
.
level
=
level
;
...
@@ -111,7 +119,7 @@
...
@@ -111,7 +119,7 @@
flags
.
unset
|=
flags_str
(
f
);
flags
.
unset
|=
flags_str
(
f
);
}
}
else
{
else
{
throw
(
"
i
nvalid flag:
"
+
f
);
writeln
(
"
* I
nvalid flag:
"
+
f
);
}
}
}
}
...
@@ -162,6 +170,12 @@
...
@@ -162,6 +170,12 @@
writeln
(
"
Modified
"
+
matches
.
length
+
"
record(s)
"
);
writeln
(
"
Modified
"
+
matches
.
length
+
"
record(s)
"
);
}
}
/* if no arguments were passed, display command usage */
if
(
argc
==
0
)
{
usage
();
return
;
}
/* parse command arguments */
/* parse command arguments */
while
(
argv
.
length
>
0
)
{
while
(
argv
.
length
>
0
)
{
var
arg
=
argv
.
shift
();
var
arg
=
argv
.
shift
();
...
@@ -171,12 +185,21 @@
...
@@ -171,12 +185,21 @@
match_rules
.
push
(
arg
);
match_rules
.
push
(
arg
);
}
}
/* if there was an error processing the request, exit */
if
(
error
)
{
writeln
(
"
\n
Error(s) processing request
"
);
return
false
;
}
/* search user list and return matches */
/* search user list and return matches */
var
matches
=
matchUsers
();
var
matches
=
matchUsers
();
/* edit matched users */
/* edit matched users */
editUsers
(
matches
,
edit_rule
);
editUsers
(
matches
,
edit_rule
);
return
true
;
})();
})();
writeln
();
This diff is collapsed.
Click to expand it.
exec/slog.js
+
9
−
5
View file @
2002aea3
(
function
()
{
(
function
()
{
writeln
(
"
\r\n
Synchronet System/Node Statistics Log Viewer
v1.02
\n
"
);
writeln
(
"
\r\n
Synchronet System/Node Statistics Log Viewer
\n
"
);
var
sfile
=
new
File
(
system
.
ctrl_dir
+
"
csts.dab
"
);
var
sfile
=
new
File
(
system
.
ctrl_dir
+
"
csts.dab
"
);
var
list
=
[];
var
list
=
[];
...
@@ -29,10 +29,14 @@
...
@@ -29,10 +29,14 @@
}
}
}
}
if
(
!
file_exists
(
sfile
.
name
))
if
(
!
file_exists
(
sfile
.
name
))
{
throw
(
sfile
.
name
+
"
does not exist
"
);
writeln
(
"
*
"
+
sfile
.
name
+
"
does not exist
"
);
if
(
!
sfile
.
open
(
'
r+b
'
))
return
false
;
throw
(
"
error opening
"
+
sfile
.
name
);
}
if
(
!
sfile
.
open
(
'
r+b
'
))
{
writeln
(
"
* error opening
"
+
sfile
.
name
);
return
false
;
}
while
(
sfile
.
position
<=
file_size
(
sfile
.
name
)
-
40
)
{
while
(
sfile
.
position
<=
file_size
(
sfile
.
name
)
-
40
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment