How to re-launch menuconf

Discuss the technical details of Gargoyle and ongoing development

Moderator: Moderators

roblad
Posts: 34
Joined: Mon Aug 05, 2013 11:04 am

Re: How to re-launch menuconf

Post by roblad »

Hi,

There is not a problem that patches are only for www js files and some of .sh scripts for www, I can skip it at all. Today I will build it without patching and I see what is going on - but in my opinions there is not a problem - that are official patches for polish release. The main reason is a iptables patch that is not needed for ramips I guess.

In ftp problem , I had similar with official build for TP-LINH 1043ND, and I found solution in official forum in vsptpd - there was some problem with file permission - I do not remember exactly.


tray this in /etc/config/vsftpd:

Code: Select all

config vsftpd
	option anonymous 'no'
	option anonymous_write 'no'

#config share
#	option share_dir '/tmp/usb_mount/dev_sda1/myshare'
#	option name      'my_share'
#	list   users_rw  'user1'
#	list   users_rw  'user2'
#	list   users_ro  'user3'
in /etc/init.d

Code: Select all

#!/bin/sh /etc/rc.common

START=90

vsftpd_basedir="/tmp/vsftpd"
vsftpd_conf="$vsftpd_basedir/vsftpd.conf"
vsftpd_anonymous_root="/tmp/share_home/anonymous"

#####################################################################################################
#
# By default vsftpd is configured per-user, with each user having a home directory
# under which that user has control.  However, ideally we want to be able to specify
# things based on shared directories, with each user having (or not having) access to
# a given shared directory.  
# 
# So... what we do is give each user a home directory under /tmp/share_home/[user_name]
# The user root is not writable, but under the user root, we mount (using the bind option)
# the shares, which may or may not be writable.  We can't just symlink, since we chroot into 
# the user directory and symlinks don't work when we chroot.  Since the share name is 
# consistent, and we chroot for each user if we specify the same share for two different
# users, the url (minus user/pass) is the same, which is exactly what we want.  Also, we
# can bind directories readonly.  This is useful since if we can't specify directory
# permissions on a mounted drive, due to the drive being formatted with a non-unix 
# filesystem, we can still specify readonly mounts.
#
###################################################################################################





found_share="0"
got_lock=0



usb_lock()
{
	got_lock=0
	local timeout=15
	
	if [ ! -e /tmp/usb_restart.lock ] ; then
		touch /tmp/usb_restart.lock
		got_lock=1
	fi
	while [ "$timeout" -gt 0 ] && [ "$got_lock" = "0" ] ; do
		sleep 1
		timeout=$(( $timeout - 1 ))
		if [ ! -e /tmp/usb_restart.lock ] ; then
			touch /tmp/usb_restart.lock
			got_lock=1
		fi
	done

	echo "$got_lock"
}

usb_unlock()
{
	rm -rf /tmp/usb_restart.lock
}



copy_if_diff()
{
	new_file="$1"
	old_file="$2"

	if   [ ! -f "$new_file" ] ; then
		return
	elif [ ! -f "$old_file" ] ; then
		cp "$new_file" "$old_file"
	else
		old_md5=$(md5sum "$old_file")
		old_md5=${old_md5% *}
		new_md5=$(md5sum "$new_file")
		new_md5=${new_md5% *}
		if [ "$old_md5" != "$new_md5" ] ; then
			cp "$new_file" "$old_file"
		fi	
	fi
}

check_mounted()
{
	local timeout=25
	local found=0
	if [ -e /tmp/mounted_usb_storage.tab ] ; then found=1 ; fi
	while [ "$timeout" -gt 0 ] && [ "$found" = "0" ] ; do
		sleep 1
		timeout=$(( $timeout - 1 ))
		if [ -e /tmp/mounted_usb_storage.tab ] ; then found=1 ; fi
	done
	echo "$found"
}


mount_share_dir()
{
	local username="$1"
	local share_id="$2"
	local write="$3"
	config_get share_dir "$share_id" share_dir
	if [ -z "$share_dir" ] ; then
		return
	fi
	if [ ! -d "$share_dir" ] ; then
		return
	fi

	local share_name
	local ftp_root
	config_get share_name "$share_id" "name"
	if [ -z "$share_name" ] ; then share_name="$share_id" ; fi

	if [ "$username" = "anonymous" ] || [ "$username" = "ftp" ] ; then
		config_get ftp_root "vsftpd" anonymous_root "$vsftpd_anonymous_root"
		username="anonymous"
	else	
		ftp_root=$(/sbin/uci get share_users.$username.home_dir 2>/dev/null)
	fi
	if [ -z "$ftp_root" ] ; then
		ftp_root="/tmp/share_home/$username"
	fi

	
	found_share="1"
	mkdir -p "$ftp_root/$share_name"  >/dev/null 2>&1
	chmod 777 "$ftp_root/$share_name" >/dev/null 2>&1
	chmod 777 "$share_dir" >/dev/null 2>&1


	chown "$username"  "$ftp_root/$share_name" >/dev/null 2>&1
	mount -o bind "$share_dir" "$ftp_root/$share_name" >/dev/null 2>&1
	if [ "$write" = "no" ] ; then
		mount -o remount,bind,ro "$ftp_root/$share_name" >/dev/null 2>&1
	fi

	# we can specify per-user write option in vsftpd config, though generally we won't use it
	config_get write "$username" write "yes"
	echo "write_enable=$write" > "$vsftpd_basedir/users/$username"


}
mount_share_rw()
{
	mount_share_dir "$1" "$2" "yes"
}
mount_share_ro()
{
	mount_share_dir "$1" "$2" "no"
}

mount_share()
{
	local share_id="$1"
	config_list_foreach "$share_id" users_rw mount_share_rw "$share_id"
	config_list_foreach "$share_id" users_ro mount_share_ro "$share_id"
	
}

global()
{
	config_get pasv_min_port $1 pasv_min_port
	config_get pasv_max_port $1 pasv_max_port

	if [ -n "$pasv_min_port" ] && [ -n "$pasv_max_port" ] ; then
		echo "pasv_min_port=$pasv_min_port" >> "$vsftpd_conf"
		echo "pasv_max_port=$pasv_max_port" >> "$vsftpd_conf"
	fi


	config_get anonymous $1 anonymous "no"
	config_get anonymous_write $1 anonymous_write "no"
	config_get anonymous_root $1 anonymous_root "$vsftpd_anonymous_root"

	local ftp_group_num=$(awk -F ":" ' $1 == "ftp" { print $3 }' /etc/group)
	local ftp_user_num=$(awk -F ":" ' $1 == "ftp" { print $3 }' /etc/passwd)
	if [ -z "$ftp_group_num" ] ; then
		ftp_group_num=55
		local tst=$(awk -F ":" -v groupnum="$ftp_group_num"  ' $3 == groupnum { print "found" }' /etc/group)
		while [ -n "$tst" ] ; do
			ftp_group_num=$(($ftp_group_num+1))
			tst=$(awk -F ":" -v groupnum="$ftp_group_num" ' $3 == groupnum { print "found" }' /etc/group)
		done
		echo "ftp:x:$ftp_group_num:" >>/etc/group
	fi
	if [ -z "$ftp_user_num" ] ; then
		ftp_user_num="$ftp_group_num"
		local tst=$(awk -F ":" -v usernum="$ftp_user_num" ' $3 == usernum { print "found" }' /etc/passwd )
		while [ -n "$tst" ] ; do
			ftp_user_num=$(($ftp_user_num+1))
			tst=$(awk -F ":" -v usernum="$ftp_user_num" ' $3 == usernum { print "found" }' /etc/passwd )
		done
		echo "ftp:*:$ftp_user_num:$ftp_group_num:ftp:$anonymous_root:/bin/false" >> /etc/passwd
	else
		local tmp_pass_file="/tmp/tmp.passwd.tmp"
		cp /etc/passwd "$tmp_pass_file"
		escaped_anonymous_root=$( echo "$anonymous_root" | sed 's/\//\\\//g' )
		sed -i "s/^ftp:.*\$/ftp:\*:$ftp_user_num:$ftp_group_num:ftp:$escaped_anonymous_root:\/bin\/false/g" "$tmp_pass_file"
		copy_if_diff "$tmp_pass_file" /etc/passwd
	fi
	
	if [ -e /etc/shadow ] ; then
		local have_shadow_ftp=$(grep '^ftp:' /etc/shadow)
		if [ -z "$have_shadow_ftp" ] ; then
			echo 'ftp:*:0:0:99999:7:::' >> /etc/shadow
		fi
	fi



	if [ "$anonymous" = "yes" ] ; then

		mkdir -p "$anonymous_root"
		chmod 555 "$anonymous_root" >/dev/null 2>&1

		echo "anon_root=$anonymous_root" >> "$vsftpd_conf"
		echo "no_anon_password=yes"      >> "$vsftpd_conf"


		if [ "$anonymous_write" = "yes" ]; then
				echo "write_enable=yes" > $vsftpd_basedir/users/ftp
		else
				echo "write_enable=no" > $vsftpd_basedir/users/ftp
		fi
		echo "ftp" >> "$vsftpd_basedir/userlist"
		echo "anonymous" >> "$vsftpd_basedir/userlist"
	else
		echo "anonymous_enable=no" >> "$vsftpd_conf"
	fi


}

update_userlist()
{
	local username="$1"
	echo "$username" >> "$vsftpd_basedir/userlist"
}

create_config()
{
	mkdir -p "$vsftpd_basedir"
	mkdir -p "$vsftpd_basedir/secure_chroot"
	mkdir -p "$vsftpd_basedir/users/"

	cat /etc/vsftpd.conf.template > "$vsftpd_conf"	
	rm       "$vsftpd_basedir/users/"*  2>/dev/null
	rm       "$vsftpd_basedir/userlist" 2>/dev/null
	touch    "$vsftpd_basedir/userlist"


	config_load "share_users"
	config_foreach update_userlist "user"


	config_load "vsftpd"
	
}

do_start()
{
	create_config
	config_load "vsftpd"
	config_foreach global "vsftpd"
	config_foreach mount_share "share"

	[ -e /etc/vsftpd.conf ] && echo "WARNING: Detected file /etc/vsftpd.conf. It will not be used."
	if [ "$found_share" != "1" ] ; then
		echo "WARNING: No shares defined, vsftpd will not be started"
	else
		start-stop-daemon  -S -x  /usr/sbin/vsftpd -- "$vsftpd_conf"
	fi
}

do_stop() {

	start-stop-daemon -K -x /usr/sbin/vsftpd 
	sleep 1

	IFS_ORIG="$IFS"
	IFS_LINEBREAK="$(printf '\n\r')"
	IFS="$IFS_LINEBREAK"
	
	user_share_mounts=$(awk   ' $2 ~ /^\/tmp\/share_home\// || /^\/var\/share_home\//  { print $2 } ' /proc/mounts)
	for m in $user_share_mounts ; do
		umount "$m" 2>/dev/null
		rm -rf "$m" 2>/dev/null
	done
	IFS="$IFS_ORIG"

}


stop()
{
	got_lock=$(usb_lock)
	if [ "$got_lock" = "1" ] ; then
		do_stop
		usb_unlock
	fi
}

start()
{
	mounted=$(check_mounted)
	logger "vsftpd init: mounted = $mounted"
	if [ "$mounted" = "1" ] ; then
		got_lock=$(usb_lock)
		logger "vsftpd init: got_lock = $got_lock"
		if [ "$got_lock" = "1" ] ; then
			do_start
			usb_unlock
		fi
	else
		echo "ERROR: No drives attached, no directories to share!"
	fi
}


restart()
{
	mounted=$(check_mounted)
	got_lock=$(usb_lock)
	if [ "$got_lock" = "1" ] ; then
		do_stop
		if [ "$mounted" = "1" ] ; then
			do_start
		fi
		usb_unlock
	fi
}

in /etc/vsftpd.conf.template

Code: Select all

anon_mkdir_write_enable=yes
anon_other_write_enable=yes
anon_umask=0000
anon_upload_enable=yes
anon_world_readable_only=no
background=yes
check_shell=no
chmod_enable=no
chroot_local_user=yes
dirlist_enable=yes
dirmessage_enable=yes
download_enable=yes
file_open_mode=0666
ftpd_banner=ftp server ready
hide_ids=no
listen_port=21
listen=yes
local_enable=yes
local_umask=0000
syslog_enable=yes
user_config_dir=/tmp/vsftpd/users
userlist_deny=no
userlist_enable=yes
userlist_file=/tmp/vsftpd/userlist
use_sendfile=no
secure_chroot_dir=/tmp/vsftpd/secure_chroot
ftp_username=ftp
my vsftpd has 96917 b size



i let you know what en build is working - but I think that it will be the same.

Regards,
RL

User avatar
ericwong
Posts: 430
Joined: Sat Aug 25, 2012 6:15 am
Location: Melbourne, Australia
Contact:

Re: How to re-launch menuconf

Post by ericwong »

roblad wrote: In ftp problem , I had similar with official build for TP-LINH 1043ND, and I found solution in official forum in vsptpd - there was some problem with file permission - I do not remember exactly.
I have tested ftp on TP-Link TL-WR1043N using Gargoyle 1.5.10 (official build), there is no user/password problem like I experienced on the RAMIPS build I compiled.

Did you see in my ftp post that I found a workaround? the only problem is the way Gargoyle modify the user/password file. Not vsftp configuration itself.

I don't think there is any problem with those few configuration files you have posted. They looks the same except this

/etc/config/vsftpd

Code: Select all

config share 'usb'
	option name 'usb'
	option share_dir '/tmp/usb_mount/dev_sda1'
	list users_rw 'backup'

config vsftpd 'global'
	option anonymous 'no'
	option anonymous_write 'no'
	option pasv_min_port '50990'
	option pasv_max_port '50999'
Eric Wong

PM me if you need to buy Gargoyle router in Australia/NZ, willing to pay me to help you on your Gargoyle configurations or build custom configured ROM with pre-installed app or try to fix your bricked router. Yes, I am looking for job/work.

User avatar
ericwong
Posts: 430
Joined: Sat Aug 25, 2012 6:15 am
Location: Melbourne, Australia
Contact:

Re: How to re-launch menuconf

Post by ericwong »

roblad wrote: 1. it is trunk AA r37174 and GG 56b0b9a2cf41f3a17ebcb7fdb72ad586d4a409a
Your gargoyle revision is different from the one I am using.
I suggest you try to build using EXACTLY the same revision I was using if you want guaranteed build success..
i.e. 62b7660

Sometimes the new changes in GG code will result in build errors like those you see... unless you can figure it out yourself.
Eric Wong

PM me if you need to buy Gargoyle router in Australia/NZ, willing to pay me to help you on your Gargoyle configurations or build custom configured ROM with pre-installed app or try to fix your bricked router. Yes, I am looking for job/work.

roblad
Posts: 34
Joined: Mon Aug 05, 2013 11:04 am

Re: How to re-launch menuconf

Post by roblad »

Hi,

I already have that rev GG through hardreset from master I downloaded it, I will start it today (I will have 3 builds running ufff - strong work for my PC)
I will see - but I reviewed git log with the changes and I did not notise important changes - for iptables i did not find anything.

I let you know what is a result.

Regards,
Robert

User avatar
ericwong
Posts: 430
Joined: Sat Aug 25, 2012 6:15 am
Location: Melbourne, Australia
Contact:

Re: How to re-launch menuconf

Post by ericwong »

roblad wrote:Hi,

I already have that rev GG through hardreset from master I downloaded it, I will start it today (I will have 3 builds running ufff - strong work for my PC)
I will see - but I reviewed git log with the changes and I did not notise important changes - for iptables i did not find anything.

I let you know what is a result.

Regards,
Robert
There is one trick you can try if it still fails at the same place.

I remembered I used this trick to get a working gargoyle build last time.
This could also be the source of my ftp user/password bug too..

After you use make custom and gargoyle created the custom-src folder, close the terminal.

Go inside custom-src and build the rom for your router.
I was doing this last time just to check and make sure the Openwrt portion is working... because the same Openwrt revision not under Gargoyle was working for me..

Leaving the custom-src folder intact, go back to gargoyle and do make custom. Gargoyle will apply all its patches on top of the custom-src code that is successfully compiled earlier..
Eric Wong

PM me if you need to buy Gargoyle router in Australia/NZ, willing to pay me to help you on your Gargoyle configurations or build custom configured ROM with pre-installed app or try to fix your bricked router. Yes, I am looking for job/work.

roblad
Posts: 34
Joined: Mon Aug 05, 2013 11:04 am

Re: How to re-launch menuconf

Post by roblad »

Ok,

I will try it, it means, when should I close the terminal ? when some build will start or just do some break in build script before starting compilation.


Regards

Robert

User avatar
ericwong
Posts: 430
Joined: Sat Aug 25, 2012 6:15 am
Location: Melbourne, Australia
Contact:

Re: How to re-launch menuconf

Post by ericwong »

roblad wrote: I will try it, it means, when should I close the terminal ? when some build will start or just do some break in build script before starting compilation.
Try stopping it when it starts compilation. That means it has finished copying the Openwrt files to custom-src.
Eric Wong

PM me if you need to buy Gargoyle router in Australia/NZ, willing to pay me to help you on your Gargoyle configurations or build custom configured ROM with pre-installed app or try to fix your bricked router. Yes, I am looking for job/work.

roblad
Posts: 34
Joined: Mon Aug 05, 2013 11:04 am

Re: How to re-launch menuconf

Post by roblad »

Hi,

I did the trick for old - your sugested repository and AA 37174 with PL patches. It stil going on with normal AA build, maibe in the morning it will finish, and I will rerun from GG mace custom, and we will see.

It is stiuped - the make/build/rebuild scripts from GG are unusable - developers should recreate it for normal people, AA is easier much more.

Regards,
Robert

BashfulBladder
Moderator
Posts: 250
Joined: Thu Jan 17, 2013 11:43 pm

Re: How to re-launch menuconf

Post by BashfulBladder »

I remember when first trying to compile on Mac OS X, the integrate_netfilter_modules.sh script required updated utilities. I specifically remember 'wc -1' causing problems.

For Mac OS X, these updated utilities were needed:
GNU head
GNU tail
wc
xargs
readline

Maybe you need an updated utility?

BTW, I enable 6 threads in build.sh/rebuild.sh (I don't know if I'm lucky on Mac OS X) & with a Core2 quad processor, it takes about 75 minutes to build everything - cross-compiler to finished images - using ar71xx.usb.
TP-Link WDR3600 v1.1 running 1.5.10+ L10n-English (Built 20130922 - OpenWrt r38093)
TP-Link WDR4300 running 1.5.10+ i18n-English (Built 20131010 - OpenWrt r38286)

https://github.com/BashfulBladder/gargoyle-plugins/wiki

roblad
Posts: 34
Joined: Mon Aug 05, 2013 11:04 am

Re: How to re-launch menuconf

Post by roblad »

Hi,

you mean that I should remove and install again these programs:

wc
xargs
readline

I use Debian - Kali Linux with full patching set.

I rerun revision that was described previously, but efect from custom-src is thesame (trick), I rerun from gargoyle dir make custom and it is right now going on - has started from crash state - I will see if it will finish. Twice, when I build elier for AA 37174 it passed through, of cource with the crash and rerun in the midel.

Do you know what could be a reason of that ?
I have to build GG for fonera20n (Edimax 1500n) .

>>>>>>

GNU head

eport head bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'head invocation'
compile@root:/media/proc$ head -v --version
head (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie and Jim Meyering.

GNU tail

compile@root:/media/proc$ tail -v --version
tail (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, David MacKenzie, Ian Lance Taylor,
and Jim Meyering.


wc


Report wc bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'wc invocation'
compile@root:/media/proc$ wc --version
wc (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


xargs


compile@root:/media/proc$ xargs --version
xargs (GNU findutils) 4.4.2
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b

readline

I did not have :-(

I installed

readline-common_6.2+dfsg-0.1_all.deb
>>>>>>


Regards,
Robert

Post Reply