<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run shell command from priv-app application in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695886#M107978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The user has no rights to perform "su" action.&lt;BR /&gt;You need to add android.permission.ACCESS_SUPERUSER permissions for the user.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Victor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Oct 2017 05:42:16 GMT</pubDate>
    <dc:creator>b36401</dc:creator>
    <dc:date>2017-10-05T05:42:16Z</dc:date>
    <item>
      <title>Run shell command from priv-app application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695885#M107977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to run shell commands from a system/priv-app I have added to the AOSP (7.1.1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The command I am trying to run is: &lt;STRONG&gt;ip link add dev can0 type can&lt;/STRONG&gt;&amp;nbsp;to switch on the can bus.&lt;/P&gt;&lt;P&gt;I have build the image as both &lt;STRONG&gt;-eng&lt;/STRONG&gt;&amp;nbsp;&amp;amp; &lt;STRONG&gt;-userdebug&amp;nbsp;&lt;/STRONG&gt;releases.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The command runs fine in the adb shell and successfully switches on the CAN bus as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that I get the following error:&amp;nbsp;&lt;EM&gt;Cannot run program "su": error=13, Permission denied&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try the following code within the system privileged java app:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;//ArrayList&amp;lt;String&amp;gt; commands is passed into the method&lt;BR /&gt; try {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (null != commands &amp;amp;&amp;amp; commands.size() &amp;gt; 0) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Process suProcess = Runtime.getRuntime().exec("su");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;for (String currCommand : commands) {&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;os.writeBytes(currCommand + "\n");&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;os.flush();&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;}&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;os.writeBytes("exit\n");&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;os.flush();&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;BufferedReader stderr = new BufferedReader(new InputStreamReader(suProcess.getErrorStream()));&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;String line = "";&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;String errString = "";&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;while ((line = stderr.readLine()) != null) errString += line + "\n";&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;suProcess.waitFor();&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;if (suProcess.exitValue() != 0)&lt;BR /&gt; &lt;SPAN style="background-color: #f6f6f6;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;throw new Exception(errString);&lt;BR /&gt; } //Handle exception&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Sep 2017 15:03:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695885#M107977</guid>
      <dc:creator>tommos23</dc:creator>
      <dc:date>2017-09-29T15:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Run shell command from priv-app application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695886#M107978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The user has no rights to perform "su" action.&lt;BR /&gt;You need to add android.permission.ACCESS_SUPERUSER permissions for the user.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Victor&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2017 05:42:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695886#M107978</guid>
      <dc:creator>b36401</dc:creator>
      <dc:date>2017-10-05T05:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Run shell command from priv-app application</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695887#M107979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply Victor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I believe android.permission.ACCESS_SUPERUSER&amp;nbsp;has been deprecated&amp;nbsp;since Android 5 and I receive the following error in the logcat report.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;W PackageManager: Unknown permission android.permission.ACCESS_SUPERUSER in package com.carnation.flexcan&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Is there another way to give an application su privileges?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Oct 2017 09:11:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Run-shell-command-from-priv-app-application/m-p/695887#M107979</guid>
      <dc:creator>tommos23</dc:creator>
      <dc:date>2017-10-05T09:11:33Z</dc:date>
    </item>
  </channel>
</rss>

