Skip to content

Commit f0b24f0

Browse files
committed
fail on EACCES to socket in SmartOS zone
1 parent f2a9b04 commit f0b24f0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

plat/sunos.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ get_product_string(void)
7676
}
7777

7878
static int
79-
find_md_ngz(const char **out)
79+
find_md_ngz(const char **out, int *permfail)
8080
{
8181
int i;
8282
struct stat st;
@@ -90,6 +90,15 @@ find_md_ngz(const char **out)
9090
S_ISSOCK(st.st_mode)) {
9191
*out = zone_md_socket_paths[i];
9292
return (0);
93+
} else {
94+
/*
95+
* If we're not root, and we get an EACCES, it's
96+
* often a permissions problem. Don't retry
97+
* forever:
98+
*/
99+
if (geteuid() != 0 && (errno == EPERM ||
100+
errno == EACCES))
101+
*permfail = 1;
93102
}
94103
}
95104

@@ -113,7 +122,7 @@ open_md_ngz(int *outfd, char **errmsg, int *permfail)
113122
* socket might not exist yet. Keep trying and wait for it to
114123
* appear.
115124
*/
116-
if (find_md_ngz(&sockpath) == -1) {
125+
if (find_md_ngz(&sockpath, permfail) == -1) {
117126
*errmsg = "Could not find metadata socket.";
118127
return (-1);
119128
}

0 commit comments

Comments
 (0)