3g/4g modem access from within chroot

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

3g/4g modem access from within chroot

Kihaguru Gathura-2
Hi,

I am able to send SMS using AT commands and C outside chroot using
code spinet below

-------------------------------------------------------------------
#include <stdio.h>
#include <time.h>
#include <unistd.h>

#define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"

int main()
{
         FILE *out;
         char s[40];

        printf("Content-type: text/html\n\n");

        snprintf(s, sizeof(s), "%s", MODEM_PATH);
~
~
~
~
~
~
        return(0);
}
--------------------------------------------------------------------

however, running the program from within chroot, I get the message

/dev/cuaU0 - No such file or directory

All files needed by cu are properly copied to chroot and cu works fine.

Question:

1: How do i get /dev/cuaU0 device accessible under chroot?

2: Is there a better i.e more secure approach to access modem from
within chroot?

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

tomr


On 09/12/18 02:45, Kihaguru Gathura wrote:

> Hi,
>
> I am able to send SMS using AT commands and C outside chroot using
> code spinet below
>
> -------------------------------------------------------------------
> #include <stdio.h>
> #include <time.h>
> #include <unistd.h>
>
> #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
>
> int main()
> {
>          FILE *out;
>          char s[40];
>
>         printf("Content-type: text/html\n\n");
>
>         snprintf(s, sizeof(s), "%s", MODEM_PATH);
> ~
> ~
> ~
> ~
> ~
> ~
>         return(0);
> }
> --------------------------------------------------------------------
>
> however, running the program from within chroot, I get the message
>
> /dev/cuaU0 - No such file or directory
>
> All files needed by cu are properly copied to chroot and cu works fine.
>
> Question:
>
> 1: How do i get /dev/cuaU0 device accessible under chroot?

# mkdir $chroot/dev
# cd $chroot/dev
# sh /dev/MAKEDEV ttyU0

Make sure the chroot isn't mounted 'nodev'.

> 2: Is there a better i.e more secure approach to access modem from
> within chroot?
>

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

Kihaguru Gathura-2
In reply to this post by Kihaguru Gathura-2
Hi,

What effective way can be used to apply permission to /dev/cuaU2 to
avoid the error below.


www# chroot -u www /var/www cgi-bin/modem
Status: 200 OK
Content-type: text/html

cu: open("/dev/cuaU2"): Permission denied

Note: chown www:daemon /dev/cuaU2 has not worked. chroot is in the
root folder which allows devices.

        /dev/sd0a (87d0b25f285b037a.a) on /mnt type ffs (rw,
asynchronous, local)
        /dev/sd0e (87d0b25f285b037a.e) on /mnt/home type ffs (rw,
asynchronous, local, nodev, nosuid)
        /dev/sd0d (87d0b25f285b037a.d) on /mnt/usr type ffs (rw,
asynchronous, local, nodev)



# dmesg
OpenBSD 6.4-current (GENERIC.MP) #253: Sun Nov  4 23:26:31 MST 2018
    [hidden email]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
real mem  = 961421312 (916MB)
avail mem = 902914048 (861MB)
mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu0: 512KB 64b/line 16-way L2 cache
efi0 at mainbus0: UEFI 2.7
efi0: Das U-Boot rev 0x20180900
simplefb0 at mainbus0: 656x416, 32bpp
wsdisplay0 at simplefb0 mux 1
wsdisplay0: screen 0-5 added (std, vt100 emulation)
simplebus0 at mainbus0: "soc"
bcmintc0 at simplebus0
bcmdog0 at simplebus0
bcmrng0 at simplebus0
pluart0 at simplebus0
bcmtemp0 at simplebus0
bcmaux0 at simplebus0
com0 at simplebus0: ns16550, no working fifo
com0: console
dwctwo0 at simplebus0
simplebus1 at mainbus0: "clocks"
agtimer0 at mainbus0: tick rate 19200 KHz
cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu1: 512KB 64b/line 16-way L2 cache
cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu2: 512KB 64b/line 16-way L2 cache
cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu3: 512KB 64b/line 16-way L2 cache
usb0 at dwctwo0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev
2.00/1.00 addr 1
uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard
Microsystems product 0x9514" rev 2.00/2.00 addr 2
smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard
Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
smsc0: address b8:27:eb:fd:e2:73
ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3:
OUI 0x0001f0, model 0x000c
umass0 at uhub1 port 3 configuration 1 interface 0 "HP v222w" rev
2.00/11.00 addr 4
umass0: using SCSI over Bulk-Only
scsibus0 at umass0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <hp, v222w, 1100> SCSI2 0/direct
removable serial.03f03f40AA0000000444
sd0: 7680MB, 512 bytes/sector, 15728640 sectors
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
scsibus2 at softraid0: 256 targets
bootfile: sd0a:/bsd
boot device: sd0
root on sd0a (87d0b25f285b037a.a) swap on sd0b dump on sd0b
WARNING: CHECK AND RESET THE DATE!
umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm0 detached
umsm1 detached
umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom0 at umsm0
umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom1 at umsm1
umsm2 at uhub1 port 5 configuration 1 interface 2 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom2 at umsm2
umass1 at uhub1 port 5 configuration 1 interface 3 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umass1: using SCSI over Bulk-Only
scsibus3 at umass1: 2 targets, initiator 0
cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
5/cdrom removable
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
uid 503 on /: file system full
coredump of postgres(24493) failed, filesystem full
uid 503 on /: file system full
uid 503 on /: file system full
ucom0 detached
umsm0 detached
ucom1 detached
umsm1 detached
ucom2 detached
umsm2 detached
cd0 detached
scsibus3 detached
umass1 detached
sd1 detached
scsibus4 detached
umass2 detached
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm0 detached
umsm1 detached
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom0 at umsm0
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom1 at umsm1
umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom2 at umsm2
umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umass1: using SCSI over Bulk-Only
scsibus3 at umass1: 2 targets, initiator 0
cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
5/cdrom removable
umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umass2: using SCSI over Bulk-Only
scsibus4 at umass2: 2 targets, initiator 0
sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
0/direct removable
ucom0 detached
umsm0 detached
ucom1 detached
umsm1 detached
ucom2 detached
umsm2 detached
cd0 detached
scsibus3 detached
umass1 detached
sd1 detached
scsibus4 detached
umass2 detached
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm0 detached
umsm1 detached
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom0 at umsm0
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom1 at umsm1
umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom2 at umsm2
umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umass1: using SCSI over Bulk-Only
scsibus3 at umass1: 2 targets, initiator 0
cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
5/cdrom removable
umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5scsibus4 at umass2: 2 targets, initiator 0
sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
0/direct removable
ucom0 detached
umsm0 detached
ucom1 detached
umsm1 detached
ucom2 detached
umsm2 detached
cd0 detached
scsibus3 detached
umass1 detached
sd1 detached
scsibus4 detached
umass2 detached
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umsm0 detached
umsm1 detached
umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom0 at umsm0
umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom1 at umsm1
umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
ucom2 at umsm2
umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umass1: using SCSI over Bulk-Only
scsibus3 at umass1: 2 targets, initiator 0
cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
5/cdrom removable
umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
Mobile" rev 2.00/1.02 addr 5
umass2: using SCSI over Bulk-Only
scsibus4 at umass2: 2 targets, initiator 0
sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
0/direct removable

Thanks,

Kihaguru.

On 9/11/18, Kihaguru Gathura <[hidden email]> wrote:

> Hi,
>
> I am able to send SMS using AT commands and C outside chroot using
> code spinet below
>
> -------------------------------------------------------------------
> #include <stdio.h>
> #include <time.h>
> #include <unistd.h>
>
> #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
>
> int main()
> {
>          FILE *out;
>          char s[40];
>
>         printf("Content-type: text/html\n\n");
>
>         snprintf(s, sizeof(s), "%s", MODEM_PATH);
> ~
> ~
> ~
> ~
> ~
> ~
>         return(0);
> }
> --------------------------------------------------------------------
>
> however, running the program from within chroot, I get the message
>
> /dev/cuaU0 - No such file or directory
>
> All files needed by cu are properly copied to chroot and cu works fine.
>
> Question:
>
> 1: How do i get /dev/cuaU0 device accessible under chroot?
>
> 2: Is there a better i.e more secure approach to access modem from
> within chroot?
>

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

Edgar Pettijohn III-2
In reply to this post by Kihaguru Gathura-2

On Feb 8, 2019 9:01 AM, Kihaguru Gathura <[hidden email]> wrote:
>
> Hi,
>
> What effective way can be used to apply permission to /dev/cuaU2 to
> avoid the error below.
>
>
> www# chroot -u www /var/www cgi-bin/modem

Is there a /var/www/dev/cuaU2

> Status: 200 OK
> Content-type: text/html
>
> cu: open("/dev/cuaU2"): Permission denied
>
> Note: chown www:daemon /dev/cuaU2 has not worked. chroot is in the
> root folder which allows devices.
>
>         /dev/sd0a (87d0b25f285b037a.a) on /mnt type ffs (rw,
> asynchronous, local)
>         /dev/sd0e (87d0b25f285b037a.e) on /mnt/home type ffs (rw,
> asynchronous, local, nodev, nosuid)
>         /dev/sd0d (87d0b25f285b037a.d) on /mnt/usr type ffs (rw,
> asynchronous, local, nodev)
>
>
>
> # dmesg
> OpenBSD 6.4-current (GENERIC.MP) #253: Sun Nov  4 23:26:31 MST 2018
>     [hidden email]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
> real mem  = 961421312 (916MB)
> avail mem = 902914048 (861MB)
> mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
> cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
> cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> cpu0: 512KB 64b/line 16-way L2 cache
> efi0 at mainbus0: UEFI 2.7
> efi0: Das U-Boot rev 0x20180900
> simplefb0 at mainbus0: 656x416, 32bpp
> wsdisplay0 at simplefb0 mux 1
> wsdisplay0: screen 0-5 added (std, vt100 emulation)
> simplebus0 at mainbus0: "soc"
> bcmintc0 at simplebus0
> bcmdog0 at simplebus0
> bcmrng0 at simplebus0
> pluart0 at simplebus0
> bcmtemp0 at simplebus0
> bcmaux0 at simplebus0
> com0 at simplebus0: ns16550, no working fifo
> com0: console
> dwctwo0 at simplebus0
> simplebus1 at mainbus0: "clocks"
> agtimer0 at mainbus0: tick rate 19200 KHz
> cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
> cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> cpu1: 512KB 64b/line 16-way L2 cache
> cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
> cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> cpu2: 512KB 64b/line 16-way L2 cache
> cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
> cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> cpu3: 512KB 64b/line 16-way L2 cache
> usb0 at dwctwo0: USB revision 2.0
> uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev
> 2.00/1.00 addr 1
> uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard
> Microsystems product 0x9514" rev 2.00/2.00 addr 2
> smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard
> Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
> smsc0: address b8:27:eb:fd:e2:73
> ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3:
> OUI 0x0001f0, model 0x000c
> umass0 at uhub1 port 3 configuration 1 interface 0 "HP v222w" rev
> 2.00/11.00 addr 4
> umass0: using SCSI over Bulk-Only
> scsibus0 at umass0: 2 targets, initiator 0
> sd0 at scsibus0 targ 1 lun 0: <hp, v222w, 1100> SCSI2 0/direct
> removable serial.03f03f40AA0000000444
> sd0: 7680MB, 512 bytes/sector, 15728640 sectors
> vscsi0 at root
> scsibus1 at vscsi0: 256 targets
> softraid0 at root
> scsibus2 at softraid0: 256 targets
> bootfile: sd0a:/bsd
> boot device: sd0
> root on sd0a (87d0b25f285b037a.a) swap on sd0b dump on sd0b
> WARNING: CHECK AND RESET THE DATE!
> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm0 detached
> umsm1 detached
> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom0 at umsm0
> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom1 at umsm1
> umsm2 at uhub1 port 5 configuration 1 interface 2 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom2 at umsm2
> umass1 at uhub1 port 5 configuration 1 interface 3 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umass1: using SCSI over Bulk-Only
> scsibus3 at umass1: 2 targets, initiator 0
> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> 5/cdrom removable
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> uid 503 on /: file system full
> coredump of postgres(24493) failed, filesystem full
> uid 503 on /: file system full
> uid 503 on /: file system full
> ucom0 detached
> umsm0 detached
> ucom1 detached
> umsm1 detached
> ucom2 detached
> umsm2 detached
> cd0 detached
> scsibus3 detached
> umass1 detached
> sd1 detached
> scsibus4 detached
> umass2 detached
> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm0 detached
> umsm1 detached
> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom0 at umsm0
> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom1 at umsm1
> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom2 at umsm2
> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umass1: using SCSI over Bulk-Only
> scsibus3 at umass1: 2 targets, initiator 0
> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> 5/cdrom removable
> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umass2: using SCSI over Bulk-Only
> scsibus4 at umass2: 2 targets, initiator 0
> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
> 0/direct removable
> ucom0 detached
> umsm0 detached
> ucom1 detached
> umsm1 detached
> ucom2 detached
> umsm2 detached
> cd0 detached
> scsibus3 detached
> umass1 detached
> sd1 detached
> scsibus4 detached
> umass2 detached
> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm0 detached
> umsm1 detached
> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom0 at umsm0
> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom1 at umsm1
> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom2 at umsm2
> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umass1: using SCSI over Bulk-Only
> scsibus3 at umass1: 2 targets, initiator 0
> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> 5/cdrom removable
> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5scsibus4 at umass2: 2 targets, initiator 0
> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
> 0/direct removable
> ucom0 detached
> umsm0 detached
> ucom1 detached
> umsm1 detached
> ucom2 detached
> umsm2 detached
> cd0 detached
> scsibus3 detached
> umass1 detached
> sd1 detached
> scsibus4 detached
> umass2 detached
> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umsm0 detached
> umsm1 detached
> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom0 at umsm0
> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom1 at umsm1
> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> ucom2 at umsm2
> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umass1: using SCSI over Bulk-Only
> scsibus3 at umass1: 2 targets, initiator 0
> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> 5/cdrom removable
> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
> Mobile" rev 2.00/1.02 addr 5
> umass2: using SCSI over Bulk-Only
> scsibus4 at umass2: 2 targets, initiator 0
> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
> 0/direct removable
>
> Thanks,
>
> Kihaguru.
>
> On 9/11/18, Kihaguru Gathura <[hidden email]> wrote:
> > Hi,
> >
> > I am able to send SMS using AT commands and C outside chroot using
> > code spinet below
> >
> > -------------------------------------------------------------------
> > #include <stdio.h>
> > #include <time.h>
> > #include <unistd.h>
> >
> > #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
> >
> > int main()
> > {
> >          FILE *out;
> >          char s[40];
> >
> >         printf("Content-type: text/html\n\n");
> >
> >         snprintf(s, sizeof(s), "%s", MODEM_PATH);
> > ~
> > ~
> > ~
> > ~
> > ~
> > ~
> >         return(0);
> > }
> > --------------------------------------------------------------------
> >
> > however, running the program from within chroot, I get the message
> >
> > /dev/cuaU0 - No such file or directory
> >
> > All files needed by cu are properly copied to chroot and cu works fine.
> >
> > Question:
> >
> > 1: How do i get /dev/cuaU0 device accessible under chroot?
> >
> > 2: Is there a better i.e more secure approach to access modem from
> > within chroot?
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

Kihaguru Gathura-2
In reply to this post by Kihaguru Gathura-2
>
> Is there a /var/www/dev/cuaU2

Indeed this is present. created it before as follows:

www# mkdir /var/www/dev
www# cd /var/www/dev
www# sh /dev/MAKEDEV ttyU2
www# ls
cuaU2 ttyU2
www#

>

On 2/8/19, Edgar Pettijohn <[hidden email]> wrote:

>
> On Feb 8, 2019 9:01 AM, Kihaguru Gathura <[hidden email]> wrote:
>>
>> Hi,
>>
>> What effective way can be used to apply permission to /dev/cuaU2 to
>> avoid the error below.
>>
>>
>> www# chroot -u www /var/www cgi-bin/modem
>
> Is there a /var/www/dev/cuaU2
>
>> Status: 200 OK
>> Content-type: text/html
>>
>> cu: open("/dev/cuaU2"): Permission denied
>>
>> Note: chown www:daemon /dev/cuaU2 has not worked. chroot is in the
>> root folder which allows devices.
>>
>>         /dev/sd0a (87d0b25f285b037a.a) on /mnt type ffs (rw,
>> asynchronous, local)
>>         /dev/sd0e (87d0b25f285b037a.e) on /mnt/home type ffs (rw,
>> asynchronous, local, nodev, nosuid)
>>         /dev/sd0d (87d0b25f285b037a.d) on /mnt/usr type ffs (rw,
>> asynchronous, local, nodev)
>>
>>
>>
>> # dmesg
>> OpenBSD 6.4-current (GENERIC.MP) #253: Sun Nov  4 23:26:31 MST 2018
>>     [hidden email]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
>> real mem  = 961421312 (916MB)
>> avail mem = 902914048 (861MB)
>> mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
>> cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
>> cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
>> cpu0: 512KB 64b/line 16-way L2 cache
>> efi0 at mainbus0: UEFI 2.7
>> efi0: Das U-Boot rev 0x20180900
>> simplefb0 at mainbus0: 656x416, 32bpp
>> wsdisplay0 at simplefb0 mux 1
>> wsdisplay0: screen 0-5 added (std, vt100 emulation)
>> simplebus0 at mainbus0: "soc"
>> bcmintc0 at simplebus0
>> bcmdog0 at simplebus0
>> bcmrng0 at simplebus0
>> pluart0 at simplebus0
>> bcmtemp0 at simplebus0
>> bcmaux0 at simplebus0
>> com0 at simplebus0: ns16550, no working fifo
>> com0: console
>> dwctwo0 at simplebus0
>> simplebus1 at mainbus0: "clocks"
>> agtimer0 at mainbus0: tick rate 19200 KHz
>> cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
>> cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
>> cpu1: 512KB 64b/line 16-way L2 cache
>> cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
>> cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
>> cpu2: 512KB 64b/line 16-way L2 cache
>> cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
>> cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
>> cpu3: 512KB 64b/line 16-way L2 cache
>> usb0 at dwctwo0: USB revision 2.0
>> uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev
>> 2.00/1.00 addr 1
>> uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard
>> Microsystems product 0x9514" rev 2.00/2.00 addr 2
>> smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard
>> Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
>> smsc0: address b8:27:eb:fd:e2:73
>> ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3:
>> OUI 0x0001f0, model 0x000c
>> umass0 at uhub1 port 3 configuration 1 interface 0 "HP v222w" rev
>> 2.00/11.00 addr 4
>> umass0: using SCSI over Bulk-Only
>> scsibus0 at umass0: 2 targets, initiator 0
>> sd0 at scsibus0 targ 1 lun 0: <hp, v222w, 1100> SCSI2 0/direct
>> removable serial.03f03f40AA0000000444
>> sd0: 7680MB, 512 bytes/sector, 15728640 sectors
>> vscsi0 at root
>> scsibus1 at vscsi0: 256 targets
>> softraid0 at root
>> scsibus2 at softraid0: 256 targets
>> bootfile: sd0a:/bsd
>> boot device: sd0
>> root on sd0a (87d0b25f285b037a.a) swap on sd0b dump on sd0b
>> WARNING: CHECK AND RESET THE DATE!
>> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm0 detached
>> umsm1 detached
>> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom0 at umsm0
>> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom1 at umsm1
>> umsm2 at uhub1 port 5 configuration 1 interface 2 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom2 at umsm2
>> umass1 at uhub1 port 5 configuration 1 interface 3 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umass1: using SCSI over Bulk-Only
>> scsibus3 at umass1: 2 targets, initiator 0
>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> 5/cdrom removable
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> coredump of postgres(24493) failed, filesystem full
>> uid 503 on /: file system full
>> uid 503 on /: file system full
>> ucom0 detached
>> umsm0 detached
>> ucom1 detached
>> umsm1 detached
>> ucom2 detached
>> umsm2 detached
>> cd0 detached
>> scsibus3 detached
>> umass1 detached
>> sd1 detached
>> scsibus4 detached
>> umass2 detached
>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm0 detached
>> umsm1 detached
>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom0 at umsm0
>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom1 at umsm1
>> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom2 at umsm2
>> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umass1: using SCSI over Bulk-Only
>> scsibus3 at umass1: 2 targets, initiator 0
>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> 5/cdrom removable
>> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umass2: using SCSI over Bulk-Only
>> scsibus4 at umass2: 2 targets, initiator 0
>> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>> 0/direct removable
>> ucom0 detached
>> umsm0 detached
>> ucom1 detached
>> umsm1 detached
>> ucom2 detached
>> umsm2 detached
>> cd0 detached
>> scsibus3 detached
>> umass1 detached
>> sd1 detached
>> scsibus4 detached
>> umass2 detached
>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm0 detached
>> umsm1 detached
>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom0 at umsm0
>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom1 at umsm1
>> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom2 at umsm2
>> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umass1: using SCSI over Bulk-Only
>> scsibus3 at umass1: 2 targets, initiator 0
>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> 5/cdrom removable
>> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5scsibus4 at umass2: 2 targets, initiator 0
>> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>> 0/direct removable
>> ucom0 detached
>> umsm0 detached
>> ucom1 detached
>> umsm1 detached
>> ucom2 detached
>> umsm2 detached
>> cd0 detached
>> scsibus3 detached
>> umass1 detached
>> sd1 detached
>> scsibus4 detached
>> umass2 detached
>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umsm0 detached
>> umsm1 detached
>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom0 at umsm0
>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom1 at umsm1
>> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> ucom2 at umsm2
>> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umass1: using SCSI over Bulk-Only
>> scsibus3 at umass1: 2 targets, initiator 0
>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> 5/cdrom removable
>> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>> Mobile" rev 2.00/1.02 addr 5
>> umass2: using SCSI over Bulk-Only
>> scsibus4 at umass2: 2 targets, initiator 0
>> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>> 0/direct removable
>>
>> Thanks,
>>
>> Kihaguru.
>>
>> On 9/11/18, Kihaguru Gathura <[hidden email]> wrote:
>> > Hi,
>> >
>> > I am able to send SMS using AT commands and C outside chroot using
>> > code spinet below
>> >
>> > -------------------------------------------------------------------
>> > #include <stdio.h>
>> > #include <time.h>
>> > #include <unistd.h>
>> >
>> > #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
>> >
>> > int main()
>> > {
>> >          FILE *out;
>> >          char s[40];
>> >
>> >         printf("Content-type: text/html\n\n");
>> >
>> >         snprintf(s, sizeof(s), "%s", MODEM_PATH);
>> > ~
>> > ~
>> > ~
>> > ~
>> > ~
>> > ~
>> >         return(0);
>> > }
>> > --------------------------------------------------------------------
>> >
>> > however, running the program from within chroot, I get the message
>> >
>> > /dev/cuaU0 - No such file or directory
>> >
>> > All files needed by cu are properly copied to chroot and cu works fine.
>> >
>> > Question:
>> >
>> > 1: How do i get /dev/cuaU0 device accessible under chroot?
>> >
>> > 2: Is there a better i.e more secure approach to access modem from
>> > within chroot?
>> >
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

Kihaguru Gathura-2
Finally this works but wish to know any security implications if any.

www# usermod -G dialer www
www# chroot -u www /var/www /cgi-bin/modem
Status: 200 OK
Content-type: text/html

Connected to /dev/cuaU2 (speed 115200)
AT+CMGF=1
OK

[EOT]
www#

Thanks

Kihaguru.

On 2/8/19, Kihaguru Gathura <[hidden email]> wrote:

>>
>> Is there a /var/www/dev/cuaU2
>
> Indeed this is present. created it before as follows:
>
> www# mkdir /var/www/dev
> www# cd /var/www/dev
> www# sh /dev/MAKEDEV ttyU2
> www# ls
> cuaU2 ttyU2
> www#
>
>>
>
> On 2/8/19, Edgar Pettijohn <[hidden email]> wrote:
>>
>> On Feb 8, 2019 9:01 AM, Kihaguru Gathura <[hidden email]> wrote:
>>>
>>> Hi,
>>>
>>> What effective way can be used to apply permission to /dev/cuaU2 to
>>> avoid the error below.
>>>
>>>
>>> www# chroot -u www /var/www cgi-bin/modem
>>
>> Is there a /var/www/dev/cuaU2
>>
>>> Status: 200 OK
>>> Content-type: text/html
>>>
>>> cu: open("/dev/cuaU2"): Permission denied
>>>
>>> Note: chown www:daemon /dev/cuaU2 has not worked. chroot is in the
>>> root folder which allows devices.
>>>
>>>         /dev/sd0a (87d0b25f285b037a.a) on /mnt type ffs (rw,
>>> asynchronous, local)
>>>         /dev/sd0e (87d0b25f285b037a.e) on /mnt/home type ffs (rw,
>>> asynchronous, local, nodev, nosuid)
>>>         /dev/sd0d (87d0b25f285b037a.d) on /mnt/usr type ffs (rw,
>>> asynchronous, local, nodev)
>>>
>>>
>>>
>>> # dmesg
>>> OpenBSD 6.4-current (GENERIC.MP) #253: Sun Nov  4 23:26:31 MST 2018
>>>     [hidden email]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
>>> real mem  = 961421312 (916MB)
>>> avail mem = 902914048 (861MB)
>>> mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
>>> cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
>>> cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>>> D-cache
>>> cpu0: 512KB 64b/line 16-way L2 cache
>>> efi0 at mainbus0: UEFI 2.7
>>> efi0: Das U-Boot rev 0x20180900
>>> simplefb0 at mainbus0: 656x416, 32bpp
>>> wsdisplay0 at simplefb0 mux 1
>>> wsdisplay0: screen 0-5 added (std, vt100 emulation)
>>> simplebus0 at mainbus0: "soc"
>>> bcmintc0 at simplebus0
>>> bcmdog0 at simplebus0
>>> bcmrng0 at simplebus0
>>> pluart0 at simplebus0
>>> bcmtemp0 at simplebus0
>>> bcmaux0 at simplebus0
>>> com0 at simplebus0: ns16550, no working fifo
>>> com0: console
>>> dwctwo0 at simplebus0
>>> simplebus1 at mainbus0: "clocks"
>>> agtimer0 at mainbus0: tick rate 19200 KHz
>>> cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
>>> cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>>> D-cache
>>> cpu1: 512KB 64b/line 16-way L2 cache
>>> cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
>>> cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>>> D-cache
>>> cpu2: 512KB 64b/line 16-way L2 cache
>>> cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
>>> cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>>> D-cache
>>> cpu3: 512KB 64b/line 16-way L2 cache
>>> usb0 at dwctwo0: USB revision 2.0
>>> uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev
>>> 2.00/1.00 addr 1
>>> uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard
>>> Microsystems product 0x9514" rev 2.00/2.00 addr 2
>>> smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard
>>> Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
>>> smsc0: address b8:27:eb:fd:e2:73
>>> ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3:
>>> OUI 0x0001f0, model 0x000c
>>> umass0 at uhub1 port 3 configuration 1 interface 0 "HP v222w" rev
>>> 2.00/11.00 addr 4
>>> umass0: using SCSI over Bulk-Only
>>> scsibus0 at umass0: 2 targets, initiator 0
>>> sd0 at scsibus0 targ 1 lun 0: <hp, v222w, 1100> SCSI2 0/direct
>>> removable serial.03f03f40AA0000000444
>>> sd0: 7680MB, 512 bytes/sector, 15728640 sectors
>>> vscsi0 at root
>>> scsibus1 at vscsi0: 256 targets
>>> softraid0 at root
>>> scsibus2 at softraid0: 256 targets
>>> bootfile: sd0a:/bsd
>>> boot device: sd0
>>> root on sd0a (87d0b25f285b037a.a) swap on sd0b dump on sd0b
>>> WARNING: CHECK AND RESET THE DATE!
>>> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm0 detached
>>> umsm1 detached
>>> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom0 at umsm0
>>> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom1 at umsm1
>>> umsm2 at uhub1 port 5 configuration 1 interface 2 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom2 at umsm2
>>> umass1 at uhub1 port 5 configuration 1 interface 3 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umass1: using SCSI over Bulk-Only
>>> scsibus3 at umass1: 2 targets, initiator 0
>>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>>> 5/cdrom removable
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> coredump of postgres(24493) failed, filesystem full
>>> uid 503 on /: file system full
>>> uid 503 on /: file system full
>>> ucom0 detached
>>> umsm0 detached
>>> ucom1 detached
>>> umsm1 detached
>>> ucom2 detached
>>> umsm2 detached
>>> cd0 detached
>>> scsibus3 detached
>>> umass1 detached
>>> sd1 detached
>>> scsibus4 detached
>>> umass2 detached
>>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm0 detached
>>> umsm1 detached
>>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom0 at umsm0
>>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom1 at umsm1
>>> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom2 at umsm2
>>> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umass1: using SCSI over Bulk-Only
>>> scsibus3 at umass1: 2 targets, initiator 0
>>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>>> 5/cdrom removable
>>> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umass2: using SCSI over Bulk-Only
>>> scsibus4 at umass2: 2 targets, initiator 0
>>> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>>> 0/direct removable
>>> ucom0 detached
>>> umsm0 detached
>>> ucom1 detached
>>> umsm1 detached
>>> ucom2 detached
>>> umsm2 detached
>>> cd0 detached
>>> scsibus3 detached
>>> umass1 detached
>>> sd1 detached
>>> scsibus4 detached
>>> umass2 detached
>>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm0 detached
>>> umsm1 detached
>>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom0 at umsm0
>>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom1 at umsm1
>>> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom2 at umsm2
>>> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umass1: using SCSI over Bulk-Only
>>> scsibus3 at umass1: 2 targets, initiator 0
>>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>>> 5/cdrom removable
>>> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5scsibus4 at umass2: 2 targets, initiator 0
>>> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>>> 0/direct removable
>>> ucom0 detached
>>> umsm0 detached
>>> ucom1 detached
>>> umsm1 detached
>>> ucom2 detached
>>> umsm2 detached
>>> cd0 detached
>>> scsibus3 detached
>>> umass1 detached
>>> sd1 detached
>>> scsibus4 detached
>>> umass2 detached
>>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umsm0 detached
>>> umsm1 detached
>>> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom0 at umsm0
>>> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom1 at umsm1
>>> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> ucom2 at umsm2
>>> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umass1: using SCSI over Bulk-Only
>>> scsibus3 at umass1: 2 targets, initiator 0
>>> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>>> 5/cdrom removable
>>> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>>> Mobile" rev 2.00/1.02 addr 5
>>> umass2: using SCSI over Bulk-Only
>>> scsibus4 at umass2: 2 targets, initiator 0
>>> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>>> 0/direct removable
>>>
>>> Thanks,
>>>
>>> Kihaguru.
>>>
>>> On 9/11/18, Kihaguru Gathura <[hidden email]> wrote:
>>> > Hi,
>>> >
>>> > I am able to send SMS using AT commands and C outside chroot using
>>> > code spinet below
>>> >
>>> > -------------------------------------------------------------------
>>> > #include <stdio.h>
>>> > #include <time.h>
>>> > #include <unistd.h>
>>> >
>>> > #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
>>> >
>>> > int main()
>>> > {
>>> >          FILE *out;
>>> >          char s[40];
>>> >
>>> >         printf("Content-type: text/html\n\n");
>>> >
>>> >         snprintf(s, sizeof(s), "%s", MODEM_PATH);
>>> > ~
>>> > ~
>>> > ~
>>> > ~
>>> > ~
>>> > ~
>>> >         return(0);
>>> > }
>>> > --------------------------------------------------------------------
>>> >
>>> > however, running the program from within chroot, I get the message
>>> >
>>> > /dev/cuaU0 - No such file or directory
>>> >
>>> > All files needed by cu are properly copied to chroot and cu works
>>> > fine.
>>> >
>>> > Question:
>>> >
>>> > 1: How do i get /dev/cuaU0 device accessible under chroot?
>>> >
>>> > 2: Is there a better i.e more secure approach to access modem from
>>> > within chroot?
>>> >
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

Edgar Pettijohn III-2
In reply to this post by Kihaguru Gathura-2

On Feb 8, 2019 2:21 PM, Kihaguru Gathura <[hidden email]> wrote:

>
> >
> > Is there a /var/www/dev/cuaU2
>
> Indeed this is present. created it before as follows:
>
> www# mkdir /var/www/dev
> www# cd /var/www/dev
> www# sh /dev/MAKEDEV ttyU2
> www# ls
> cuaU2 ttyU2
> www#
>
> >
>
> On 2/8/19, Edgar Pettijohn <[hidden email]> wrote:
> >
> > On Feb 8, 2019 9:01 AM, Kihaguru Gathura <[hidden email]> wrote:
> >>
> >> Hi,
> >>
> >> What effective way can be used to apply permission to /dev/cuaU2 to
> >> avoid the error below.
> >>
> >>
> >> www# chroot -u www /var/www cgi-bin/modem
> >
> > Is there a /var/www/dev/cuaU2
> >
> >> Status: 200 OK
> >> Content-type: text/html
> >>
> >> cu: open("/dev/cuaU2"): Permission denied
> >>
> >> Note: chown www:daemon /dev/cuaU2 has not worked. chroot is in the
> >> root folder which allows devices.

What about chown www:daemon /var/www/dev/cuaU0

> >>
> >>         /dev/sd0a (87d0b25f285b037a.a) on /mnt type ffs (rw,
> >> asynchronous, local)
> >>         /dev/sd0e (87d0b25f285b037a.e) on /mnt/home type ffs (rw,
> >> asynchronous, local, nodev, nosuid)
> >>         /dev/sd0d (87d0b25f285b037a.d) on /mnt/usr type ffs (rw,
> >> asynchronous, local, nodev)
> >>

Where is /var/www mounted?

> >>
> >>
> >> # dmesg
> >> OpenBSD 6.4-current (GENERIC.MP) #253: Sun Nov  4 23:26:31 MST 2018
> >>     [hidden email]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
> >> real mem  = 961421312 (916MB)
> >> avail mem = 902914048 (861MB)
> >> mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
> >> cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
> >> cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> >> cpu0: 512KB 64b/line 16-way L2 cache
> >> efi0 at mainbus0: UEFI 2.7
> >> efi0: Das U-Boot rev 0x20180900
> >> simplefb0 at mainbus0: 656x416, 32bpp
> >> wsdisplay0 at simplefb0 mux 1
> >> wsdisplay0: screen 0-5 added (std, vt100 emulation)
> >> simplebus0 at mainbus0: "soc"
> >> bcmintc0 at simplebus0
> >> bcmdog0 at simplebus0
> >> bcmrng0 at simplebus0
> >> pluart0 at simplebus0
> >> bcmtemp0 at simplebus0
> >> bcmaux0 at simplebus0
> >> com0 at simplebus0: ns16550, no working fifo
> >> com0: console
> >> dwctwo0 at simplebus0
> >> simplebus1 at mainbus0: "clocks"
> >> agtimer0 at mainbus0: tick rate 19200 KHz
> >> cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
> >> cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> >> cpu1: 512KB 64b/line 16-way L2 cache
> >> cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
> >> cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> >> cpu2: 512KB 64b/line 16-way L2 cache
> >> cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
> >> cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
> >> cpu3: 512KB 64b/line 16-way L2 cache
> >> usb0 at dwctwo0: USB revision 2.0
> >> uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev
> >> 2.00/1.00 addr 1
> >> uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard
> >> Microsystems product 0x9514" rev 2.00/2.00 addr 2
> >> smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard
> >> Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
> >> smsc0: address b8:27:eb:fd:e2:73
> >> ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3:
> >> OUI 0x0001f0, model 0x000c
> >> umass0 at uhub1 port 3 configuration 1 interface 0 "HP v222w" rev
> >> 2.00/11.00 addr 4
> >> umass0: using SCSI over Bulk-Only
> >> scsibus0 at umass0: 2 targets, initiator 0
> >> sd0 at scsibus0 targ 1 lun 0: <hp, v222w, 1100> SCSI2 0/direct
> >> removable serial.03f03f40AA0000000444
> >> sd0: 7680MB, 512 bytes/sector, 15728640 sectors
> >> vscsi0 at root
> >> scsibus1 at vscsi0: 256 targets
> >> softraid0 at root
> >> scsibus2 at softraid0: 256 targets
> >> bootfile: sd0a:/bsd
> >> boot device: sd0
> >> root on sd0a (87d0b25f285b037a.a) swap on sd0b dump on sd0b
> >> WARNING: CHECK AND RESET THE DATE!
> >> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm0 detached
> >> umsm1 detached
> >> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom0 at umsm0
> >> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom1 at umsm1
> >> umsm2 at uhub1 port 5 configuration 1 interface 2 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom2 at umsm2
> >> umass1 at uhub1 port 5 configuration 1 interface 3 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umass1: using SCSI over Bulk-Only
> >> scsibus3 at umass1: 2 targets, initiator 0
> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> >> 5/cdrom removable
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> coredump of postgres(24493) failed, filesystem full
> >> uid 503 on /: file system full
> >> uid 503 on /: file system full
> >> ucom0 detached
> >> umsm0 detached
> >> ucom1 detached
> >> umsm1 detached
> >> ucom2 detached
> >> umsm2 detached
> >> cd0 detached
> >> scsibus3 detached
> >> umass1 detached
> >> sd1 detached
> >> scsibus4 detached
> >> umass2 detached
> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm0 detached
> >> umsm1 detached
> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom0 at umsm0
> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom1 at umsm1
> >> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom2 at umsm2
> >> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umass1: using SCSI over Bulk-Only
> >> scsibus3 at umass1: 2 targets, initiator 0
> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> >> 5/cdrom removable
> >> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umass2: using SCSI over Bulk-Only
> >> scsibus4 at umass2: 2 targets, initiator 0
> >> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
> >> 0/direct removable
> >> ucom0 detached
> >> umsm0 detached
> >> ucom1 detached
> >> umsm1 detached
> >> ucom2 detached
> >> umsm2 detached
> >> cd0 detached
> >> scsibus3 detached
> >> umass1 detached
> >> sd1 detached
> >> scsibus4 detached
> >> umass2 detached
> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm0 detached
> >> umsm1 detached
> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom0 at umsm0
> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom1 at umsm1
> >> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom2 at umsm2
> >> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umass1: using SCSI over Bulk-Only
> >> scsibus3 at umass1: 2 targets, initiator 0
> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> >> 5/cdrom removable
> >> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5scsibus4 at umass2: 2 targets, initiator 0
> >> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
> >> 0/direct removable
> >> ucom0 detached
> >> umsm0 detached
> >> ucom1 detached
> >> umsm1 detached
> >> ucom2 detached
> >> umsm2 detached
> >> cd0 detached
> >> scsibus3 detached
> >> umass1 detached
> >> sd1 detached
> >> scsibus4 detached
> >> umass2 detached
> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umsm0 detached
> >> umsm1 detached
> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom0 at umsm0
> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom1 at umsm1
> >> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> ucom2 at umsm2
> >> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umass1: using SCSI over Bulk-Only
> >> scsibus3 at umass1: 2 targets, initiator 0
> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
> >> 5/cdrom removable
> >> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
> >> Mobile" rev 2.00/1.02 addr 5
> >> umass2: using SCSI over Bulk-Only
> >> scsibus4 at umass2: 2 targets, initiator 0
> >> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
> >> 0/direct removable
> >>
> >> Thanks,
> >>
> >> Kihaguru.
> >>
> >> On 9/11/18, Kihaguru Gathura <[hidden email]> wrote:
> >> > Hi,
> >> >
> >> > I am able to send SMS using AT commands and C outside chroot using
> >> > code spinet below
> >> >
> >> > -------------------------------------------------------------------
> >> > #include <stdio.h>
> >> > #include <time.h>
> >> > #include <unistd.h>
> >> >
> >> > #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
> >> >
> >> > int main()
> >> > {
> >> >          FILE *out;
> >> >          char s[40];
> >> >
> >> >         printf("Content-type: text/html\n\n");
> >> >
> >> >         snprintf(s, sizeof(s), "%s", MODEM_PATH);
> >> > ~
> >> > ~
> >> > ~
> >> > ~
> >> > ~
> >> > ~
> >> >         return(0);
> >> > }
> >> > --------------------------------------------------------------------
> >> >
> >> > however, running the program from within chroot, I get the message
> >> >
> >> > /dev/cuaU0 - No such file or directory
> >> >
> >> > All files needed by cu are properly copied to chroot and cu works fine.
> >> >
> >> > Question:
> >> >
> >> > 1: How do i get /dev/cuaU0 device accessible under chroot?
> >> >
> >> > 2: Is there a better i.e more secure approach to access modem from
> >> > within chroot?
> >> >
> >>
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: 3g/4g modem access from within chroot

Kihaguru Gathura-2
In reply to this post by Kihaguru Gathura-2
Have removed the group assginment and instead did chown as follows:

        www# chown www:daemon /var/www/dev/cuaU2
        www# chroot -u www /var/www /gathura/modem
        Status: 200 OK
        Content-type: text/html

        Connected to /dev/cuaU2 (speed 115200)
        AT+CMGF=1
        OK

        [EOT]
        www#

Thanks Edgar

Kihaguru.

On 2/8/19, Edgar Pettijohn <[hidden email]> wrote:

>
> On Feb 8, 2019 2:21 PM, Kihaguru Gathura <[hidden email]> wrote:
>>
>> >
>> > Is there a /var/www/dev/cuaU2
>>
>> Indeed this is present. created it before as follows:
>>
>> www# mkdir /var/www/dev
>> www# cd /var/www/dev
>> www# sh /dev/MAKEDEV ttyU2
>> www# ls
>> cuaU2 ttyU2
>> www#
>>
>> >
>>
>> On 2/8/19, Edgar Pettijohn <[hidden email]> wrote:
>> >
>> > On Feb 8, 2019 9:01 AM, Kihaguru Gathura <[hidden email]> wrote:
>> >>
>> >> Hi,
>> >>
>> >> What effective way can be used to apply permission to /dev/cuaU2 to
>> >> avoid the error below.
>> >>
>> >>
>> >> www# chroot -u www /var/www cgi-bin/modem
>> >
>> > Is there a /var/www/dev/cuaU2
>> >
>> >> Status: 200 OK
>> >> Content-type: text/html
>> >>
>> >> cu: open("/dev/cuaU2"): Permission denied
>> >>
>> >> Note: chown www:daemon /dev/cuaU2 has not worked. chroot is in the
>> >> root folder which allows devices.
>
> What about chown www:daemon /var/www/dev/cuaU0

This is a better option than assigning www to group dialer.

>
>> >>
>> >>         /dev/sd0a (87d0b25f285b037a.a) on /mnt type ffs (rw,
>> >> asynchronous, local)
>> >>         /dev/sd0e (87d0b25f285b037a.e) on /mnt/home type ffs (rw,
>> >> asynchronous, local, nodev, nosuid)
>> >>         /dev/sd0d (87d0b25f285b037a.d) on /mnt/usr type ffs (rw,
>> >> asynchronous, local, nodev)
>> >>
>
> Where is /var/www mounted?

Mounted on /dev/sd0a

>
>> >>
>> >>
>> >> # dmesg
>> >> OpenBSD 6.4-current (GENERIC.MP) #253: Sun Nov  4 23:26:31 MST 2018
>> >>
>> >> [hidden email]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
>> >> real mem  = 961421312 (916MB)
>> >> avail mem = 902914048 (861MB)
>> >> mainbus0 at root: Raspberry Pi 3 Model B Rev 1.2
>> >> cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
>> >> cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>> >> D-cache
>> >> cpu0: 512KB 64b/line 16-way L2 cache
>> >> efi0 at mainbus0: UEFI 2.7
>> >> efi0: Das U-Boot rev 0x20180900
>> >> simplefb0 at mainbus0: 656x416, 32bpp
>> >> wsdisplay0 at simplefb0 mux 1
>> >> wsdisplay0: screen 0-5 added (std, vt100 emulation)
>> >> simplebus0 at mainbus0: "soc"
>> >> bcmintc0 at simplebus0
>> >> bcmdog0 at simplebus0
>> >> bcmrng0 at simplebus0
>> >> pluart0 at simplebus0
>> >> bcmtemp0 at simplebus0
>> >> bcmaux0 at simplebus0
>> >> com0 at simplebus0: ns16550, no working fifo
>> >> com0: console
>> >> dwctwo0 at simplebus0
>> >> simplebus1 at mainbus0: "clocks"
>> >> agtimer0 at mainbus0: tick rate 19200 KHz
>> >> cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
>> >> cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>> >> D-cache
>> >> cpu1: 512KB 64b/line 16-way L2 cache
>> >> cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
>> >> cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>> >> D-cache
>> >> cpu2: 512KB 64b/line 16-way L2 cache
>> >> cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
>> >> cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1
>> >> D-cache
>> >> cpu3: 512KB 64b/line 16-way L2 cache
>> >> usb0 at dwctwo0: USB revision 2.0
>> >> uhub0 at usb0 configuration 1 interface 0 "Broadcom DWC2 root hub" rev
>> >> 2.00/1.00 addr 1
>> >> uhub1 at uhub0 port 1 configuration 1 interface 0 "Standard
>> >> Microsystems product 0x9514" rev 2.00/2.00 addr 2
>> >> smsc0 at uhub1 port 1 configuration 1 interface 0 "Standard
>> >> Microsystems SMSC9512/14" rev 2.00/2.00 addr 3
>> >> smsc0: address b8:27:eb:fd:e2:73
>> >> ukphy0 at smsc0 phy 1: Generic IEEE 802.3u media interface, rev. 3:
>> >> OUI 0x0001f0, model 0x000c
>> >> umass0 at uhub1 port 3 configuration 1 interface 0 "HP v222w" rev
>> >> 2.00/11.00 addr 4
>> >> umass0: using SCSI over Bulk-Only
>> >> scsibus0 at umass0: 2 targets, initiator 0
>> >> sd0 at scsibus0 targ 1 lun 0: <hp, v222w, 1100> SCSI2 0/direct
>> >> removable serial.03f03f40AA0000000444
>> >> sd0: 7680MB, 512 bytes/sector, 15728640 sectors
>> >> vscsi0 at root
>> >> scsibus1 at vscsi0: 256 targets
>> >> softraid0 at root
>> >> scsibus2 at softraid0: 256 targets
>> >> bootfile: sd0a:/bsd
>> >> boot device: sd0
>> >> root on sd0a (87d0b25f285b037a.a) swap on sd0b dump on sd0b
>> >> WARNING: CHECK AND RESET THE DATE!
>> >> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm0 detached
>> >> umsm1 detached
>> >> umsm0 at uhub1 port 5 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom0 at umsm0
>> >> umsm1 at uhub1 port 5 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom1 at umsm1
>> >> umsm2 at uhub1 port 5 configuration 1 interface 2 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom2 at umsm2
>> >> umass1 at uhub1 port 5 configuration 1 interface 3 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umass1: using SCSI over Bulk-Only
>> >> scsibus3 at umass1: 2 targets, initiator 0
>> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> >> 5/cdrom removable
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> coredump of postgres(24493) failed, filesystem full
>> >> uid 503 on /: file system full
>> >> uid 503 on /: file system full
>> >> ucom0 detached
>> >> umsm0 detached
>> >> ucom1 detached
>> >> umsm1 detached
>> >> ucom2 detached
>> >> umsm2 detached
>> >> cd0 detached
>> >> scsibus3 detached
>> >> umass1 detached
>> >> sd1 detached
>> >> scsibus4 detached
>> >> umass2 detached
>> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm0 detached
>> >> umsm1 detached
>> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom0 at umsm0
>> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom1 at umsm1
>> >> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom2 at umsm2
>> >> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umass1: using SCSI over Bulk-Only
>> >> scsibus3 at umass1: 2 targets, initiator 0
>> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> >> 5/cdrom removable
>> >> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umass2: using SCSI over Bulk-Only
>> >> scsibus4 at umass2: 2 targets, initiator 0
>> >> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>> >> 0/direct removable
>> >> ucom0 detached
>> >> umsm0 detached
>> >> ucom1 detached
>> >> umsm1 detached
>> >> ucom2 detached
>> >> umsm2 detached
>> >> cd0 detached
>> >> scsibus3 detached
>> >> umass1 detached
>> >> sd1 detached
>> >> scsibus4 detached
>> >> umass2 detached
>> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm0 detached
>> >> umsm1 detached
>> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom0 at umsm0
>> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom1 at umsm1
>> >> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom2 at umsm2
>> >> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umass1: using SCSI over Bulk-Only
>> >> scsibus3 at umass1: 2 targets, initiator 0
>> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> >> 5/cdrom removable
>> >> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5scsibus4 at umass2: 2 targets, initiator 0
>> >> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>> >> 0/direct removable
>> >> ucom0 detached
>> >> umsm0 detached
>> >> ucom1 detached
>> >> umsm1 detached
>> >> ucom2 detached
>> >> umsm2 detached
>> >> cd0 detached
>> >> scsibus3 detached
>> >> umass1 detached
>> >> sd1 detached
>> >> scsibus4 detached
>> >> umass2 detached
>> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umsm0 detached
>> >> umsm1 detached
>> >> umsm0 at uhub1 port 2 configuration 1 interface 0 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom0 at umsm0
>> >> umsm1 at uhub1 port 2 configuration 1 interface 1 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom1 at umsm1
>> >> umsm2 at uhub1 port 2 configuration 1 interface 2 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> ucom2 at umsm2
>> >> umass1 at uhub1 port 2 configuration 1 interface 3 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umass1: using SCSI over Bulk-Only
>> >> scsibus3 at umass1: 2 targets, initiator 0
>> >> cd0 at scsibus3 targ 1 lun 0: <HUAWEI, Mass Storage, 2.31> SCSI2
>> >> 5/cdrom removable
>> >> umass2 at uhub1 port 2 configuration 1 interface 4 "HUAWEI HUAWEI
>> >> Mobile" rev 2.00/1.02 addr 5
>> >> umass2: using SCSI over Bulk-Only
>> >> scsibus4 at umass2: 2 targets, initiator 0
>> >> sd1 at scsibus4 targ 1 lun 0: <HUAWEI, SD Storage, 2.31> SCSI2
>> >> 0/direct removable
>> >>
>> >> Thanks,
>> >>
>> >> Kihaguru.
>> >>
>> >> On 9/11/18, Kihaguru Gathura <[hidden email]> wrote:
>> >> > Hi,
>> >> >
>> >> > I am able to send SMS using AT commands and C outside chroot using
>> >> > code spinet below
>> >> >
>> >> > -------------------------------------------------------------------
>> >> > #include <stdio.h>
>> >> > #include <time.h>
>> >> > #include <unistd.h>
>> >> >
>> >> > #define MODEM_PATH "cu -l /dev/cuaU0 -s 115200"
>> >> >
>> >> > int main()
>> >> > {
>> >> >          FILE *out;
>> >> >          char s[40];
>> >> >
>> >> >         printf("Content-type: text/html\n\n");
>> >> >
>> >> >         snprintf(s, sizeof(s), "%s", MODEM_PATH);
>> >> > ~
>> >> > ~
>> >> > ~
>> >> > ~
>> >> > ~
>> >> > ~
>> >> >         return(0);
>> >> > }
>> >> > --------------------------------------------------------------------
>> >> >
>> >> > however, running the program from within chroot, I get the message
>> >> >
>> >> > /dev/cuaU0 - No such file or directory
>> >> >
>> >> > All files needed by cu are properly copied to chroot and cu works
>> >> > fine.
>> >> >
>> >> > Question:
>> >> >
>> >> > 1: How do i get /dev/cuaU0 device accessible under chroot?
>> >> >
>> >> > 2: Is there a better i.e more secure approach to access modem from
>> >> > within chroot?
>> >> >
>> >>
>> >
>>
>