Termux-packages: Package Request: samba (smbd) and cifs-utils

Created on 7 Nov 2019  路  8Comments  路  Source: termux/termux-packages

Package description

  • Samba is a "SMB/CIFS file, print, and login server for Unix", which means it can provide Windows share functionality.
  • The CIFS filesystem allows "SMB/CIFS shares to be mounted on Linux".

More on both: https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/

Link to home page and sources

  1. Home page: https://www.samba.org//
  2. Source code:

Additional information
I haven't personally tried to compile Samba on my devices, but many apps exist in the store that provide a pre-built Samba binary.

These apps are not directly useful, but it shows that Samba would work as intended when compiled for the device.

package request

Most helpful comment

pkg install unstable-repo
pkg install samba

I did the two steps above and there is some samba related folders in ../usr/var/ but nothing in../usr/etc. where should I put thesmb.conf` ?

All 8 comments

Yeah would be nice some v2 v3 support.

Tried https://forum.xda-developers.com/showpost.php?p=8239139&postcount=128
But it is v1, cannot connect from my Mac.

Tried https://github.com/jophxy/samba
Could not build, after configure and make it errors out with a server.o with no rule to make.

I want to start all the daemons from a script within termux, so my workaround was to install apache2 and the php7 module for it, and using a php file manager gained access to the entire fs from a browser.

  1. Get samba-3.5.9.tar.gz :
    curl 'https://download.samba.org/pub/samba/stable/samba-3.5.9.tar.gz' --location --output ./samba-3.5.9.tar.gz
    tar zxf samba-3.5.9.tar.gz
    cd samba-3.5.9/source3/

  2. Change file:
    vi ./lib/system.c

/***********************
Wrappers for getpwnam(), getpwuid(), getgrnam(), getgrgid()
*************************/
// gcb add
static struct passwd rootpw = {
"root",
"root",
0,
0,
"root",
"/root"
"/data/data/com.termux/files/usr/bin/sh",
};
static char *rootmem[] = {
"root"
};
static struct group rootgr = {
"root",
"root",
0,
rootmem,
};
//gcb add end

struct passwd *sys_getpwnam(const char *name)
{
//return getpwnam(name); //gcb comment
return &rootpw; // gcb add
}

struct passwd *sys_getpwuid(uid_t uid)
{
//return getpwuid(uid); //gcb comment
return &rootpw;
}

struct group *sys_getgrnam(const char *name)
{
//return getgrnam(name); //gcb comment
return &rootgr;
}

struct group *sys_getgrgid(gid_t gid)
{
//return getgrgid(gid); //gcb comment
return &rootgr;
}

  1. Add config shell script:
    vi ./my_android_config.sh

CROSS_COMPILE=/home/drteam/gcb/Pie/prebuilts/gcc/linux-arm/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-
RUNTIME_DIR=/data/data/com.termux/files/usr
./configure \
CC="$CROSS_COMPILE"gcc \
AR="$CROSS_COMPILE"ar \
LD="$CROSS_COMPILE"ld \
RANLIB="$CROSS_COMPILE"ranlib \
--without-krb5 --without-ldap --without-ads --enable-static=yes --disable-shared \
--disable-cups --enable-swat=no --with-winbind=no \
--target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--disable-cups \
--disable-iprint \
--prefix=$RUNTIME_DIR \
--exec-prefix=$RUNTIME_DIR \
--with-logfilebase=$RUNTIME_DIR/var/log \
--with-swatdir=$RUNTIME_DIR/usr/local/swat \
--with-rootsbindir=$RUNTIME_DIR/sbin \
--with-lockdir=$RUNTIME_DIR/var/lock \
--with-piddir=$RUNTIME_DIR/var/lock \
--with-privatedir=$RUNTIME_DIR/etc/samba \
--with-configdir=$RUNTIME_DIR/etc/samba \
--cache-file=armsel-linux.cache \
--with-static-modules=vfs_fake_perms \
samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
libreplace_cv_HAVE_GETADDRINFO=no \
ac_cv_file__proc_sys_kernel_core_pattern=yes

  1. Compile:

chmod +x ./my_android_config.sh
./my_android_config.sh
make -j48 LDFLAGS="-all-static -static"

  1. Push smbd to your termux system:
    scp -P 8022 ./bin/{smbd,nmbd,smbpasswd} [email protected]:/data/data/com.termux/files/usr/bin/
    ssh -p 8022 [email protected] "chmod +x ~/../usr/bin/*"
    ssh -p 8022 [email protected] "mkdir ~/../usr/etc/samba/ ; mkdir ~/../usr/var/{lock,tmp,log}"

  2. Add your samba config:

vi ./smb.conf

[global]
interfaces = wlan0 eth0 lo
workgroup = WORKGROUP
server string = Samba on Android
netbios name = ANDROID
remote announce = 255.255.255.255
encrypt passwords = yes
security = user
restrict anonymous = 1
load printers = no
printcap name = /dev/null
disable spoolss = yes
deadtime = 5
delete readonly = yes
nt acl support = no
inherit permissions = yes
socket options = SO_SNDBUF=16384 SO_RCVBUF=16384

[sdcard]
vfs objects = fake_perms
comment = Android /mnt/sdcard
path = /mnt/sdcard
force user = root
read only = no
writable = yes
guest ok = no

  1. Push the config file to your termux system:
    scp -P 8022 ./smb.conf [email protected]:/data/data/com.termux/files/usr/etc/samba/

  2. Start your SMB server on your Android device:

ssh -p 8022 [email protected]
pkg install proot
proot -0 smbpasswd -a gcb
proot -0 smdb -p 1445 -D &
proot -0 nmbd -D &

  1. Connect your Android device SMB server with file explorer app

@gxbhgcb https://github.com/termux/unstable-packages/tree/master/packages/samba


Closing as samba is already added to unstable repo.

pkg install unstable-repo
pkg install samba

Thanks! I compiled with source code and it works well also.

pkg install unstable-repo
pkg install samba

I did the two steps above and there is some samba related folders in ../usr/var/ but nothing in../usr/etc. where should I put thesmb.conf` ?

This package not work for me

@gxbhgcb https://github.com/termux/unstable-packages/tree/master/packages/samba

Closing as samba is already added to unstable repo.

pkg install unstable-repo
pkg install samba

Not working at all. Where is smb.conf?

@forever8938 cp $PREFIX/share/doc/samba/smb.conf.example to $PREFIX/etc/smb.conf and modify it with your settings

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reggi picture reggi  路  4Comments

thurask picture thurask  路  3Comments

Cyb3rD3m0n picture Cyb3rD3m0n  路  3Comments

StephanBeer picture StephanBeer  路  3Comments

Zuccace picture Zuccace  路  3Comments