Skip to content

Commit

Permalink
Fix commands access check.
Browse files Browse the repository at this point in the history
Fixes ECS-20
  • Loading branch information
mremond committed Mar 29, 2016
2 parents aa15148 + 3809b89 commit 3b2d0fd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions sql/lite.sql
Expand Up @@ -19,6 +19,9 @@
CREATE TABLE users (
username text PRIMARY KEY,
password text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

Expand Down
3 changes: 3 additions & 0 deletions sql/mssql.sql
Expand Up @@ -362,6 +362,9 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW
CREATE TABLE [dbo].[users] (
[username] [varchar] (250) NOT NULL,
[password] [text] NOT NULL,
[serverkey] [text] NOT NULL,
[salt] [text] NOT NULL,
[iterationcount] [smallint] NOT NULL DEFAULT 0,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [users_PRIMARY] PRIMARY KEY CLUSTERED
(
Expand Down
5 changes: 4 additions & 1 deletion sql/mysql.sql
Expand Up @@ -19,10 +19,13 @@
CREATE TABLE users (
username varchar(191) PRIMARY KEY,
password text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- To support SCRAM auth:
-- Add support for SCRAM auth to a database created before ejabberd 16.03:
-- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0;
Expand Down
5 changes: 4 additions & 1 deletion sql/pg.sql
Expand Up @@ -19,10 +19,13 @@
CREATE TABLE users (
username text PRIMARY KEY,
"password" text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT now()
);

-- To support SCRAM auth:
-- Add support for SCRAM auth to a database created before ejabberd 16.03:
-- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ejabberd_ctl.erl
Expand Up @@ -214,7 +214,7 @@ process(Args) ->
process2(["--auth", User, Server, Pass | Args], AccessCommands) ->
process2(Args, {list_to_binary(User), list_to_binary(Server), list_to_binary(Pass), true}, AccessCommands);
process2(Args, AccessCommands) ->
process2(Args, admin, AccessCommands).
process2(Args, noauth, AccessCommands).

process2(Args, Auth, AccessCommands) ->
case try_run_ctp(Args, Auth, AccessCommands) of
Expand Down

0 comments on commit 3b2d0fd

Please sign in to comment.