Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings whitelist #892

Merged
merged 2 commits into from
Apr 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/settings/XEH_PREP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PREP(import);
PREP(export);
PREP(clear);
PREP(priority);
PREP(whitelisted);

if (hasInterface) then {
PREP(openSettingsMenu);
Expand Down
39 changes: 39 additions & 0 deletions addons/settings/fnc_whitelisted.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* ----------------------------------------------------------------------------
Internal Function: CBA_settings_fnc_whitelisted

Description:
Check if local machine can edit server settings.

Parameters:
None.

Returns:
_return - Can change server settings? <BOOL>

Examples:
(begin example)
[] call CBA_settings_fnc_whitelisted
(end)

Author:
commy2
---------------------------------------------------------------------------- */
#include "script_component.hpp"

private _uid = getPlayerUID player;
private _whitelist = getArray configFile/QGVAR(whitelist);

private _cfgMissionList = missionConfigFile/QGVAR(whitelist);
if (isArray _cfgMissionList) then {
_whitelist append getArray _cfgMissionList;
};

// if neither addon nor mission have white list, use wildcard for admin instead
if (_whitelist isEqualTo []) then {
_whitelist = ["admin"];
};

// admin wildcard and local machine is logged in admin
if ("admin" in _whitelist && {IS_ADMIN_LOGGED}) exitWith {true};

_uid in _whitelist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe _whitelist should be GVAR and set at mission init, then FUNC(whitelisted) become getPlayerUID player in GVAR(whitelist)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, "admin" in GVAR(whitelist) && {IS_ADMIN_LOGGED} || {getPlayerUID player in GVAR(whitelist)}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then you can't set it with addon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would give the ability to dynamically add entries to the variables. Meaning admins with debug console access can just add themselves to the list. Which is exactly what the original Request wanted to prevent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also true. But with the debug console, you can mess with the settings anyway if you know what you're doing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then you can't set it with addon.

why? configFile/QGVAR(whitelist) should exist on mission init.

Copy link
Contributor

@dedmen dedmen Feb 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can mess with the settings anyway if you know what you're doing.

But not with config files.

But then you can't set it with addon.

Think commy missunderstood. ala GVAR != config.

I prefer the current state.

Copy link
Contributor

@Dystopian Dystopian Feb 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current state doesn't give any additional security because like commy2 said you can easily manage settings manually with debug console. But ability to change whitelist during mission could be helpful in some cases.

2 changes: 1 addition & 1 deletion addons/settings/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

#define ICON_DEFAULT "\a3\3den\Data\Displays\Display3DEN\ToolBar\undo_ca.paa"

#define CAN_SET_SERVER_SETTINGS ((isServer || {IS_ADMIN_LOGGED}) && {!isNull GVAR(server)}) // in single player, as host (local server) or as logged in (not voted) admin connected to a dedicated server
#define CAN_SET_SERVER_SETTINGS ((isServer || FUNC(whitelisted)) && {!isNull GVAR(server)}) // in single player, as host (local server) or as logged in (not voted) admin connected to a dedicated server
#define CAN_SET_CLIENT_SETTINGS !isServer // in multiplayer as dedicated client
#define CAN_SET_MISSION_SETTINGS (is3den && {!(missionName in ["", "tempMissionSP", "tempMissionMP"])}) // in editor with existing mission.sqm

Expand Down