-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handler and systemd activation errors
On panic from handler: log warning and stack trace, report InternalServerError to client When using `podman system service` make determining the listening endpoint deterministic. // When determining _*THE*_ listening endpoint -- // 1) User input wins always // 2) systemd socket activation // 3) rootless honors XDG_RUNTIME_DIR // 4) if varlink -- adapter.DefaultVarlinkAddress // 5) lastly adapter.DefaultAPIAddress Fixes #5150 Fixes #5151 Signed-off-by: Jhon Honce <jhonce@redhat.com>
- Loading branch information
Showing
8 changed files
with
133 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package systemd | ||
|
||
import ( | ||
"os" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// Determine if podman is running under the socket activation protocol | ||
func SocketActivated() (int, bool) { | ||
pid, pid_found := os.LookupEnv("LISTEN_PID") | ||
fds, fds_found := os.LookupEnv("LISTEN_FDS") | ||
fdnames, fdnames_found := os.LookupEnv("LISTEN_FDNAMES") | ||
|
||
if !(pid_found && fds_found && fdnames_found) { | ||
return 0, false | ||
} | ||
|
||
p, err := strconv.Atoi(pid) | ||
if err != nil || p != os.Getpid() { | ||
return 0, false | ||
} | ||
|
||
nfds, err := strconv.Atoi(fds) | ||
if err != nil || nfds < 1 { | ||
return 0, false | ||
} | ||
|
||
if nfds > 1 { | ||
names := strings.Split(fdnames, ":") | ||
for i, n := range names { | ||
if strings.Contains(n, "podman") { | ||
return 3 + i, true | ||
} | ||
} | ||
} | ||
|
||
// First available file descriptor is always 3. | ||
return 3, true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package systemdgen | ||
package systemd | ||
|
||
import ( | ||
"bytes" | ||
|
2 changes: 1 addition & 1 deletion
2
pkg/systemdgen/systemdgen_test.go → pkg/systemd/systemdgen_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package systemdgen | ||
package systemd | ||
|
||
import ( | ||
"testing" | ||
|