Skip to content

Commit

Permalink
Clarify error message when not root
Browse files Browse the repository at this point in the history
nbd-client requires root to set up devices. The error message when we
are not root was less than helpful.

Fix.

Closes: gh-167

Signed-off-by: Wouter Verhelst <[email protected]>
  • Loading branch information
yoe committed Aug 6, 2024
1 parent 4664b8d commit 99cb654
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nbd-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,13 @@ static void netlink_configure(int index, int *sockfds, int num_connects,
}
nla_nest_end(msg, sock_attr);

if (nl_send_sync(socket, msg) < 0)
err("Failed to setup device, check dmesg\n");
if (nl_send_sync(socket, msg) < 0) {
if(geteuid() != 0) {
err("Failed to setup device. Are you root?\n");
} else {
err("Failed to setup device, check dmesg\n");
}
}
return;
nla_put_failure:
err("Failed to create netlink message\n");
Expand Down

0 comments on commit 99cb654

Please sign in to comment.