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

jetcd-launcher: allow starting Etcd Container via non-root user on Linux #1390

Merged
merged 1 commit into from
Aug 8, 2024
Merged

jetcd-launcher: allow starting Etcd Container via non-root user on Linux #1390

merged 1 commit into from
Aug 8, 2024

Conversation

linghengqian
Copy link
Contributor

@linghengqian linghengqian commented Aug 8, 2024

linghengqian@DESKTOP-2OCN434:~/TwinklingLiftWorks/git/public/shardingsphere$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:102:105::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:103:106:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
syslog:x:104:111::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
uuidd:x:106:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:107:113::/nonexistent:/usr/sbin/nologin
linghengqian:x:1000:1000:,,,:/home/linghengqian:/bin/bash
usbmux:x:108:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
rtkit:x:109:117:RealtimeKit,,,:/proc:/usr/sbin/nologin
  • For other systems, I don't have a local verification environment. To test the current PR in other projects, just execute the following command.
sdk install java 17.0.11-ms
sdk use java 17.0.11-ms
git clone git@github.com:linghengqian/jetcd.git -b fix-not-root-user
cd ./jetcd/
./gradlew clean publishToMavenLocal
  • Then use it directly.
<dependency>
            <groupId>io.etcd</groupId>
            <artifactId>jetcd-test</artifactId>
            <version>0.8.3-fix-not-root-user-SNAPSHOT</version>
            <scope>test</scope>
</dependency>

@@ -63,6 +64,8 @@ public class EtcdContainer extends GenericContainer<EtcdContainer> {
private Path dataDirectory;
private Collection<String> additionalArgs;
private boolean shouldMountDataDirectory = true;
private boolean rootless = true;
private String user = "1000";
Copy link
Collaborator

Choose a reason for hiding this comment

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

it should not be set to an arbitrary number by default better to leave it empty

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, once user is set it and then run with specially user, otherwise, not doing anything here at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RegisterExtension
    public static final EtcdClusterExtension CLUSTER = EtcdClusterExtension.builder()
            .withNodes(1)
            .withUser("1000:1000")
            .build();
  • Or,
@RegisterExtension
    public static final EtcdClusterExtension CLUSTER = EtcdClusterExtension.builder()
            .withNodes(1)
            .withMountDirectory(false)
            .build();
  • This still looks weird to me, but I don't want to change the default value of withMountDirectory in this PR. Maybe another friend will need to file a PR to change the unit tests.

@linghengqian linghengqian changed the title Start Etcd Docker container as non-root user on Linux Allow starting Etcd Container via non-root user on Linux Aug 8, 2024
@linghengqian linghengqian changed the title Allow starting Etcd Container via non-root user on Linux jetcd-launcher: allow starting Etcd Container via non-root user on Linux Aug 8, 2024
For #1310

Signed-off-by: linghengqian <linghengqian@outlook.com>
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lburgazzoli, linghengqian

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lburgazzoli lburgazzoli merged commit 7fc1e00 into etcd-io:main Aug 8, 2024
9 checks passed
@linghengqian linghengqian deleted the fix-not-root-user branch August 8, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants