title: How to create new user with custom home directory in rpm
body: <p>I'm attempting to create an RPM that needs to add a user with a custom home directory. In the preinstall script, it attempts to execute this command (yes, myapp already exists):</p>
  
  <pre><code>useradd -c "My Application's User" -d /usr/myapp -f 0 -s /bin/bash -g myapp myapp
  </code></pre>
  
  <p>If I execute this command as root, it works fine. If I execute this command via RPM when running as root, I get the following error:</p>
  
  <pre><code>useradd: cannot create directory /usr/myapp
  </code></pre>
  
  <p>Does RPM run as a different user when installing/running install scripts? Is there a way to accomplish what I'm trying to accomplish?</p>
  
  <p>Thanks!</p>