# Com.webos.service.power

**URL:** <https://forum.webosose.org/t/com-webos-service-power/310>\
**Category:** App Development\
**Created:** [April 19, 2018, 10:18am UTC](https://forum.webosose.org/t/com-webos-service-power/310 "2018-04-19T10:18:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahbaz](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@shahbaz](https://forum.webosose.org/u/shahbaz)\
**Post date:** [April 19, 2018, 10:18am UTC](https://forum.webosose.org/t/com-webos-service-power/310/1 "2018-04-19T10:18:09Z")

</div>

I want to reboot the device from the application, tried LS2 API Service

```
com.webos.service.power

```

Below in the Code Snippet

```
<script type="text/javascript">
			
   //sample code for calling LS2 API
   var lunaReq= webOS.service.request("luna://com.webos.service.power/shutdown/machineOff",{ 
        parameters:{
        "reason":"power off"
},
        onSuccess: function (args) {
			console.log("SUCCESS");
        },
        onFailure: function (args) {
			console.log(JSON.stringify(args));
        }
    });
</script>

```

The above code fails with following error

```
{"returnValue":false,"errorCode":-1,"errorText":"Denied method call \"machineOff\" for category \"/shutdown\""}

```

Now I want to know why this happens and if its a permission problem than what should I do ?

---

<div class="post-metadata">

**Author:** ![Garredow](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.webosose.org/garredow/32/60_2.png) [@Garredow](https://forum.webosose.org/u/Garredow)\
**Post date:** [April 19, 2018, 3:24pm UTC](https://forum.webosose.org/t/com-webos-service-power/310/2 "2018-04-19T15:24:33Z")

</div>

I haven’t looked into it, but I would assume that’s just a protected method. You wouldn’t want any app to be able to power off or reboot your device, right? In the old days, your app would need to be in the `com.palm.app`domain to get access to all the system APIs. That’s what some of us homebrew developers did to get around it. I don’t know if that’s still true for webOS OSE.

---

<div class="post-metadata">

**Author:** ![Herrie](https://avatars.discourse-cdn.com/v4/letter/h/45deac/32.png) [@Herrie](https://forum.webosose.org/u/Herrie)\
**Post date:** [April 19, 2018, 8:46pm UTC](https://forum.webosose.org/t/com-webos-service-power/310/3 "2018-04-19T20:46:07Z")

</div>

Garredow is right there. If you look in [https://github.com/webosose/luna-service2-security-conf/blob/761191b1ff6ce4465e62109f8c9a0d018108d435/files/sysbus/compat.api.json](https://github.com/webosose/luna-service2-security-conf/blob/761191b1ff6ce4465e62109f8c9a0d018108d435/files/sysbus/compat.api.json) you’ll see that it’s in the private api, so that means only com.webos or com.palm apps would have access to this.

Previously you could “fool” it a bit by either giving your app an appid that starts with com.palm or com.webos. Alternatively you could try to pretend to be sending the command from another app.

Best would be to try with the luna-send command in ssh.

luna-send accepts -a and -h parameters if I recall correctly to put the caller. Some mor example of luna-send can be found on WebOS Internals site: [http://www.webos-internals.org/wiki/Luna\_Send](http://www.webos-internals.org/wiki/Luna_Send)

This is legacy webOS used on phones, but should work similarly.

See [https://github.com/webOS-ports/org.webosports.messaging/blob/71ee04d6139997676a8d659d0ea42fbe8b37893f/service/javascript/assistants/PutMessage.js#L17](https://github.com/webOS-ports/org.webosports.messaging/blob/71ee04d6139997676a8d659d0ea42fbe8b37893f/service/javascript/assistants/PutMessage.js#L17) for an example on how to use -a.

---

<div class="post-metadata">

**Author:** ![shahbaz](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@shahbaz](https://forum.webosose.org/u/shahbaz)\
**Post date:** [April 20, 2018, 9:23am UTC](https://forum.webosose.org/t/com-webos-service-power/310/4 "2018-04-20T09:23:07Z")

</div>

@Herrie

How can I access these private API’s do I need to build my application as _Built-in-Web-Apps_ as suggested by [http://webosose.org/develop/web-app-dev/built-in-web-app/build-test-web-app/](http://webosose.org/develop/web-app-dev/built-in-web-app/build-test-web-app/) or is there any other way ?

---

<div class="post-metadata">

**Author:** ![Changhyeok](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.webosose.org/changhyeok/32/247_2.png) [@Changhyeok](https://forum.webosose.org/u/Changhyeok)\
**Post date:** [April 24, 2018, 12:44am UTC](https://forum.webosose.org/t/com-webos-service-power/310/5 "2018-04-24T00:44:02Z")

</div>

@Junil Could you let us know how to access private API?

---

<div class="post-metadata">

**Author:** ![rtoepfer](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.webosose.org/rtoepfer/32/105_2.png) [@rtoepfer](https://forum.webosose.org/u/rtoepfer)\
**Post date:** [May 18, 2018, 3:18pm UTC](https://forum.webosose.org/t/com-webos-service-power/310/6 "2018-05-18T15:18:48Z")

</div>

I had to create a dynamic JS service running as root that uses a shell command to luna-send to get around the private restriction. I guess you could recompile the whole image changing up the compat.api.json file that was mentioned before as well.

---

<div class="post-metadata">

**Author:** ![peow](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@peow](https://forum.webosose.org/u/peow)\
**Post date:** [March 5, 2019, 9:57am UTC](https://forum.webosose.org/t/com-webos-service-power/310/7 "2019-03-05T09:57:31Z")

</div>

Hi, I would like to know how you create the JS service running as root priviledge.

---

<div class="post-metadata">

**Author:** ![Andersenz](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@Andersenz](https://forum.webosose.org/u/Andersenz)\
**Post date:** [March 11, 2019, 11:15am UTC](https://forum.webosose.org/t/com-webos-service-power/310/8 "2019-03-11T11:15:29Z")

</div>

Check Below Solution..

a temporary solution, but got it to work in a pinch:

/usr/bin/sudo /bin/bash -lc 'bundle exec rails server -e demo -p 80'

```auto

Can run with a user who has sudo privileges in a systemd unit file like so:

```

[Unit]  
Description=Rails Webserver  
After=syslog.target

[Service]  
Type=simple  
User=ubuntu  
WorkingDirectory=/var/www/webserver  
ExecStart=/usr/bin/sudo /bin/bash -lc 'bundle exec rails server -e demo -p 80'  
Restart=always  
KillSignal=SIGQUIT

[Install]  
WantedBy=multi-user.target

* * *

[Showbox](https://showbox.store/)

---

<div class="post-metadata">

**Author:** ![n-jay](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.webosose.org/n-jay/32/126_2.png) [@n-jay](https://forum.webosose.org/u/n-jay)\
**Post date:** [March 12, 2019, 3:51am UTC](https://forum.webosose.org/t/com-webos-service-power/310/9 "2019-03-12T03:51:53Z")

</div>

Speaking of which doesn't webOS have any capability similar to what Android has with their [Device Administration feature](https://developer.android.com/guide/topics/admin/device-admin)?  
I was working on writing a webOS agent for an EMM product some time back and this struck me as odd considering how valuable it would be for use cases such as TVs in hotels.
