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

Fix #146. #149

Closed
wants to merge 3 commits into from
Closed

Fix #146. #149

wants to merge 3 commits into from

Conversation

shove70
Copy link

@shove70 shove70 commented Apr 16, 2019

Fix #146: on macOS: std.json.JSONException@std/json.d(155): JSONValue is not a string

Fix #146: on macOS: std.json.JSONException@std/json.d(155): JSONValue is not a string
@s-ludwig
Copy link
Member

Did you have a look at your /etc/vibe/vibe.conf or ~/vibe.conf (if any of those exist) to see which field causes the exception?

What I'm thinking is that the most appropriate approach to deal with this is to improve the generated error message to somthing like "Malformed configuration field 'xxx' in /etc/vibe/vibe.conf: JSONValue is not a string". Just converting to string could lead to another exception later on, which may be even harder to track down to the root cause.

@shove70
Copy link
Author

shove70 commented Apr 27, 2019

$ cat /etc/vibe/vibe.conf

{
	"uid": 70,
	"gid": 70
}

"uid" and "gid" are int types.

./source/vibe/core/core.d: (line: 1435-1439)

	version (VibeNoDefaultArgs) {}
	else {
		readOption("uid|user", &s_privilegeLoweringUserName, "Sets the user name or id used for privilege lowering.");
		readOption("gid|group", &s_privilegeLoweringGroupName, "Sets the group name or id used for privilege lowering.");
	}

s_privilegeLoweringUserName and s_privilegeLoweringGroupName are string types, So the template parameter that calls the template readOption is string type.

So, the more complicated modification is to change here.
Where do you think it should be revised?

@shove70
Copy link
Author

shove70 commented Apr 27, 2019

Like this?

	version (VibeNoDefaultArgs) {}
	else {
		readOption("user", &s_privilegeLoweringUserName, "Sets the user name or id used for privilege lowering.");
		readOption("group", &s_privilegeLoweringGroupName, "Sets the group name or id used for privilege lowering.");

		if (s_privilegeLoweringUserName.empty || s_privilegeLoweringGroupName.empty)
		{
			int uid, gid;
			readOption("uid", &uid, "Sets the user name or id used for privilege lowering.");
			readOption("gid", &gid, "Sets the group name or id used for privilege lowering.");

			s_privilegeLoweringUserName = uid.to!string;
			s_privilegeLoweringGroupName = gid.to!string;
		}
	}

@shove70
Copy link
Author

shove70 commented Apr 27, 2019

In the vibe.d project, the vibe.conf file generated by the shell file ./setup-mac.sh,

If quotation marks are added to the values of "uid" and "gid", this problem can also be avoided. Which solution do you think is more appropriate?

echo -e '{
	"uid": '$USER_ID',
	"gid": '$GROUP_ID'
}' >$CONFIG_FILE

Modified to:

echo -e '{
	"uid": "'$USER_ID'",
	"gid": "'$GROUP_ID'"
}' >$CONFIG_FILE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

on macOS: std.json.JSONException@std/json.d(155): JSONValue is not a string
2 participants