lsa4_srv: Factor out dcesrc_lsa_valid_AccountRight()
authorVolker Lendecke <vl@samba.org>
Thu, 27 Apr 2017 11:37:42 +0000 (13:37 +0200)
committerJeremy Allison <jra@samba.org>
Sat, 29 Apr 2017 07:20:02 +0000 (09:20 +0200)
commit277eac1a8e7443bae125e030000309e7eeea2799
tree5c6832bf7239a5993748b9eb8db22abbb077275b
parentaa43d0d81baa497135a17e843b05336b4a504809
lsa4_srv: Factor out dcesrc_lsa_valid_AccountRight()

The previous code in dcesrv_lsa_AddRemoveAccountRights had the following snippet:

if (sec_privilege_id(rights->names[i].string) == SEC_PRIV_INVALID) {
        if (sec_right_bit(rights->names[i].string) == 0) {
                talloc_free(msg);
                return NT_STATUS_NO_SUCH_PRIVILEGE;
        }
        talloc_free(msg);
        return NT_STATUS_NO_SUCH_PRIVILEGE;
}

If I'm not mistaken, the inner if-statement is essentially dead code,
as regardless of the outcome of the if-condition we execute the same
code. The effect of this is that you can't "net rpc rights grant" a right,
for example SeInteractiveLogonRight. A quick test against a W2k12 server
shows that W2k12 allows this call.

This patch changes the semantics of dcesrv_lsa_AddRemoveAccountRights
to also allow "rights" to be granted and revoked. At the same
time, it centralizes the check for validity of user input from
dcesrv_lsa_EnumAccountsWithUserRight into dcesrc_lsa_valid_AccountRight
too.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Apr 29 09:20:02 CEST 2017 on sn-devel-144
source4/rpc_server/lsa/dcesrv_lsa.c