We want to take control of the user's environment. For now the
custom shell profile only sets the prompt, but it will later
be used to influence the build environment.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
guests/tasks/users.yml | 17 +++++++++++++++++
guests/templates/bash_profile | 1 +
guests/templates/bashrc | 1 +
3 files changed, 19 insertions(+)
create mode 100644 guests/templates/bash_profile
create mode 100644 guests/templates/bashrc
diff --git a/guests/tasks/users.yml b/guests/tasks/users.yml
index 1ecacee..8e59fa9 100644
--- a/guests/tasks/users.yml
+++ b/guests/tasks/users.yml
@@ -82,3 +82,20 @@
owner: '{{ flavor }}'
group: '{{ flavor }}'
create: yes
+
+- name: '{{ flavor }}: Create shell profile'
+ template:
+ src: templates/{{ item }}
+ dest: /home/{{ flavor }}/.{{ item }}
+ owner: '{{ flavor }}'
+ group: '{{ flavor }}'
+ with_items:
+ - bash_profile
+ - bashrc
+
+- name: '{{ flavor }}: Remove existing shell profile'
+ file:
+ path: /home/{{ flavor }}/.{{ item }}
+ state: absent
+ with_items:
+ - profile
diff --git a/guests/templates/bash_profile b/guests/templates/bash_profile
new file mode 100644
index 0000000..a82a60e
--- /dev/null
+++ b/guests/templates/bash_profile
@@ -0,0 +1 @@
+test -f ~/.bashrc && . ~/.bashrc
diff --git a/guests/templates/bashrc b/guests/templates/bashrc
new file mode 100644
index 0000000..6640da6
--- /dev/null
+++ b/guests/templates/bashrc
@@ -0,0 +1 @@
+export PS1="[\u@\h \w]\$ "
--
2.14.3
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Apr 05, 2018 at 02:22:13PM +0200, Andrea Bolognani wrote: > We want to take control of the user's environment. For now the > custom shell profile only sets the prompt, but it will later > be used to influence the build environment. > > Signed-off-by: Andrea Bolognani <abologna@redhat.com> > --- > guests/tasks/users.yml | 17 +++++++++++++++++ > guests/templates/bash_profile | 1 + > guests/templates/bashrc | 1 + > 3 files changed, 19 insertions(+) > create mode 100644 guests/templates/bash_profile > create mode 100644 guests/templates/bashrc > > diff --git a/guests/tasks/users.yml b/guests/tasks/users.yml > index 1ecacee..8e59fa9 100644 > --- a/guests/tasks/users.yml > +++ b/guests/tasks/users.yml > @@ -82,3 +82,20 @@ > owner: '{{ flavor }}' > group: '{{ flavor }}' > create: yes > + > +- name: '{{ flavor }}: Create shell profile' > + template: > + src: templates/{{ item }} > + dest: /home/{{ flavor }}/.{{ item }} > + owner: '{{ flavor }}' > + group: '{{ flavor }}' > + with_items: > + - bash_profile > + - bashrc > + > +- name: '{{ flavor }}: Remove existing shell profile' > + file: > + path: /home/{{ flavor }}/.{{ item }} > + state: absent > + with_items: > + - profile > diff --git a/guests/templates/bash_profile b/guests/templates/bash_profile > new file mode 100644 > index 0000000..a82a60e > --- /dev/null > +++ b/guests/templates/bash_profile > @@ -0,0 +1 @@ > +test -f ~/.bashrc && . ~/.bashrc > diff --git a/guests/templates/bashrc b/guests/templates/bashrc > new file mode 100644 > index 0000000..6640da6 > --- /dev/null > +++ b/guests/templates/bashrc > @@ -0,0 +1 @@ > +export PS1="[\u@\h \w]\$ " I think that we should also load the system profile /etc/profile .. in case of 'jenkins' flavor we don't actually need it since that is used in automated tests but in case of 'test' flavor when developer will manually login into the guests might miss some features configured by thy system profile. Pavel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, 2018-04-06 at 14:58 +0200, Pavel Hrdina wrote: > > diff --git a/guests/templates/bash_profile b/guests/templates/bash_profile > > new file mode 100644 > > index 0000000..a82a60e > > --- /dev/null > > +++ b/guests/templates/bash_profile > > @@ -0,0 +1 @@ > > +test -f ~/.bashrc && . ~/.bashrc > > diff --git a/guests/templates/bashrc b/guests/templates/bashrc > > new file mode 100644 > > index 0000000..6640da6 > > --- /dev/null > > +++ b/guests/templates/bashrc > > @@ -0,0 +1 @@ > > +export PS1="[\u@\h \w]\$ " > > I think that we should also load the system profile /etc/profile .. in > case of 'jenkins' flavor we don't actually need it since that is used in > automated tests but in case of 'test' flavor when developer will > manually login into the guests might miss some features configured by > thy system profile. What kind of features are you thinking about, exactly? /etc/profile can vary significantly between Linux versions, and on FreeBSD it's not even loaded when using bash as the login shell IIUC; however, in all cases the resulting environment is generally pretty sane, so adding our own custom settings on top through the user's profile works nicely. Moreover, overriding setting in the user's profile instead of tweaking them globally is a better approach in general IMHO, so if there are specific features you'd like to address I would still rather deal with them in the user's profile if at all possible. -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, 2018-04-06 at 15:10 +0200, Andrea Bolognani wrote: > > I think that we should also load the system profile /etc/profile .. in > > case of 'jenkins' flavor we don't actually need it since that is used in > > automated tests but in case of 'test' flavor when developer will > > manually login into the guests might miss some features configured by > > thy system profile. > > What kind of features are you thinking about, exactly? > > /etc/profile can vary significantly between Linux versions, and on > FreeBSD it's not even loaded when using bash as the login shell > IIUC; however, in all cases the resulting environment is generally > pretty sane, so adding our own custom settings on top through the > user's profile works nicely. > > Moreover, overriding setting in the user's profile instead of > tweaking them globally is a better approach in general IMHO, so if > there are specific features you'd like to address I would still > rather deal with them in the user's profile if at all possible. Okay, so it looks like I misunderstood your comment: you were advocating for sourcing /etc/profile in the user's shell profile. bash will actually load that file regardless, and on all Linux distributions the result is that features such as bash completion will be available to the user right after login, even with our custom shell profile in place. FreeBSD, of course, behaves a little differently ;) You have to source the bash_completion script manually if you want that feature, as /etc/profile is tailored to the classic Bourne shell so it won't do that for you, and there is no such thing as a global bashrc that you can use. All in all, it's pretty simple to add, but I think it's okay for it to be a follow-up patch. Are there more features you had in mind? -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Fri, Apr 06, 2018 at 04:39:44PM +0200, Andrea Bolognani wrote: > On Fri, 2018-04-06 at 15:10 +0200, Andrea Bolognani wrote: > > > I think that we should also load the system profile /etc/profile .. in > > > case of 'jenkins' flavor we don't actually need it since that is used in > > > automated tests but in case of 'test' flavor when developer will > > > manually login into the guests might miss some features configured by > > > thy system profile. > > > > What kind of features are you thinking about, exactly? > > > > /etc/profile can vary significantly between Linux versions, and on > > FreeBSD it's not even loaded when using bash as the login shell > > IIUC; however, in all cases the resulting environment is generally > > pretty sane, so adding our own custom settings on top through the > > user's profile works nicely. > > > > Moreover, overriding setting in the user's profile instead of > > tweaking them globally is a better approach in general IMHO, so if > > there are specific features you'd like to address I would still > > rather deal with them in the user's profile if at all possible. > > Okay, so it looks like I misunderstood your comment: you were > advocating for sourcing /etc/profile in the user's shell profile. > > bash will actually load that file regardless, and on all Linux > distributions the result is that features such as bash completion > will be available to the user right after login, even with our > custom shell profile in place. > > FreeBSD, of course, behaves a little differently ;) You have to > source the bash_completion script manually if you want that > feature, as /etc/profile is tailored to the classic Bourne shell > so it won't do that for you, and there is no such thing as a > global bashrc that you can use. > > All in all, it's pretty simple to add, but I think it's okay for > it to be a follow-up patch. Are there more features you had in > mind? In that case and for FreeBSD there is no need to handle it. I was mostly concerned about Linux distributions. Reviewed-by: Pavel Hrdina <phrdina@redhat.com> -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.