<div dir="ltr"><font face="garamond, times new roman, serif" size="4">Lennart Poettering, wrote:</font><div><font face="garamond, times new roman, serif" size="4"><br></font></div><div><font face="garamond, times new roman, serif" size="4"> I think we probably should change systemd-logind to<br>implicitly and unconditionally keep an open fd to the home dir of a<br>user around as long as there's at least one session of them around,<br>simply to make clear that sessions keep home dirs busy. This, as side<br>effect would then also mean that autofs wouldn#t be tempted to<br>consider the home dir idle as long as there's a session.</font><br></div><div><font face="garamond, times new roman, serif" size="4"><br></font></div><div><font size="4" face="arial, sans-serif">Benjamin Godfrey's reply:</font></div><div><font face="arial, sans-serif"><br></font></div><div><font size="4" face="arial, sans-serif">That seems like a good idea. This can be done simply by modifying the</font> <span style="color:rgb(153,105,0);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre;background-color:rgb(0,255,255)">logind_handle_homedir_umount</span><span style="background-color:rgb(248,250,253);color:rgb(153,105,0);font-family:"Google Sans Mono",monospace;font-size:14px;white-space:pre"> </span><span style="background-color:rgb(248,250,253);white-space:pre"><font color="#000000"><font size="4" style="" face="arial, sans-serif">function</font><font size="4" face="arial, sans-serif" style=""> to:</font></font></span></div><div><br></div><div><div class="gmail-response-container-content" style="margin-top:4px;overflow-x:hidden;color:rgba(0,0,0,0.87);font-family:Tinos;font-size:medium"><span class="gmail-model-response-text gmail-ng-tns-c3575597595-34 gmail-ng-star-inserted" id="gmail-message-content-idr_95515d70c6153758" style="display:block;overflow-x:hidden;width:859.265px"><div class="gmail-markdown" style="font-size:1rem;line-height:1.5rem;font-family:"Google Sans","Helvetica Neue",sans-serif"><div class="gmail-code-block gmail-ng-star-inserted" style="margin:16px 0px"><div class="gmail-code-block-wrapper gmail-header gmail-gmat-subhead-2" style="font-size:0.875rem;line-height:1.25rem;padding:8px 16px;min-height:24px;display:flex;border-radius:16px 16px 0px 0px">C</div><pre style="margin-top:0px;margin-bottom:0px"><code role="text" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:0.875rem;line-height:1.125rem;font-family:"Google Sans Mono",monospace;border-radius:6px;padding:16px;display:block;overflow-x:auto"><span class="gmail-hljs-function"><span class="gmail-hljs-keyword">static</span> <span class="gmail-hljs-keyword">void</span>
<span class="gmail-hljs-title">logind_handle_homedir_umount</span><span class="gmail-hljs-params">(struct logind_client *client,
<span class="gmail-hljs-keyword">const</span> <span class="gmail-hljs-keyword">char</span> *homedir)</span></span></code><code role="text" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:0.875rem;line-height:1.125rem;font-family:"Google Sans Mono",monospace;border-radius:6px;padding:16px;display:block;overflow-x:auto">### The function takes two arguments client and homedir. client points to a <span style="background-color:rgb(0,255,255)">struct loginid_client</span> object</code><code role="text" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:0.875rem;line-height:1.125rem;font-family:"Google Sans Mono",monospace;border-radius:6px;padding:16px;display:block;overflow-x:auto">### and homedir is a string that points to the users homedir. </code><code role="text" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:0.875rem;line-height:1.125rem;font-family:"Google Sans Mono",monospace;border-radius:6px;padding:16px;display:block;overflow-x:auto">{
<span class="gmail-hljs-class"><span class="gmail-hljs-keyword">struct</span> <span class="gmail-hljs-title">logind_session</span> *<span class="gmail-hljs-title">session</span>;</span>
<span class="gmail-hljs-keyword">bool</span> active_sessions = <span class="gmail-hljs-literal">false</span>; ### This sets the variable to false by default
session = logind_client_find_session_by_homedir(client, homedir);
<span class="gmail-hljs-keyword">if</span> (session) {
active_sessions = <span class="gmail-hljs-literal">true</span>; ### There is an active session
}
<span class="gmail-hljs-keyword">if</span> (active_sessions) {
<span class="gmail-hljs-keyword">return</span>; ### A session is active, don't shut down.
}
logind_session_kill(session); ### Shut it down because there is no active session by default.
}</code></pre></div></div></span></div></div></div>