Re: [OpenWrt-Devel] [PATCH 3/6] pptpd: Add uci configuration for PPTPD.

2013-10-17 Thread Bruno Randolf

On 10/15/2013 02:45 PM, Jo-Philipp Wich wrote:

comments inline.


Hi, Thanks, will address the issues and resend.

bruno


On 11.10.2013 12:30, Bruno Randolf wrote:

Signed-off-by: Bruno Randolf b...@einfach.org
---
  net/pptpd/Makefile|  3 +++
  net/pptpd/files/pptpd.init| 40 ++--
  net/pptpd/files/pptpd.uciconf |  8 
  3 files changed, 49 insertions(+), 2 deletions(-)
  create mode 100644 net/pptpd/files/pptpd.uciconf

diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
index e79e0a7..0a2f642 100644
--- a/net/pptpd/Makefile
+++ b/net/pptpd/Makefile
@@ -41,6 +41,7 @@ MAKE_FLAGS += \
  define Package/pptpd/conffiles
  /etc/pptpd.conf
  /etc/ppp/options.pptpd
+/etc/config/pptpd
  endef

  define Package/pptpd/install
@@ -58,6 +59,8 @@ define Package/pptpd/install
$(INSTALL_BIN) ./files/pptpd.init $(1)/etc/init.d/pptpd
$(INSTALL_DIR) $(1)/etc/ppp
$(INSTALL_DATA) ./files/options.pptpd $(1)/etc/ppp/
+   $(INSTALL_DIR) $(1)/etc/config
+   $(INSTALL_DATA) ./files/pptpd.uciconf $(1)/etc/config/pptpd


Per convention, shipped uci configs are called program.config in files/.


  endef

  $(eval $(call BuildPackage,pptpd))
diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
index a74973c..79c0ab6 100644
--- a/net/pptpd/files/pptpd.init
+++ b/net/pptpd/files/pptpd.init
@@ -6,14 +6,50 @@ BIN=pptpd
  DEFAULT=/etc/default/$BIN
  RUN_D=/var/run
  PID_F=$RUN_D/$BIN.pid
+CONFIG=/tmp/pptpd.conf


For consistency, native configs autogenerated from uci should go into
the /var/etc directory.


+CHAP_SECRETS=/etc/ppp/chap-secrets


This should reside in /var/etc or /var/run, if pptp cannot be isntructed
to look for this file there it should be symlinked there.



-start() {
+setup_user() {
+   local section=$1
+
+   config_get user $section user
+   config_get passwd $section passwd
+   [ -n $user ] || return 0
+   [ -n $passwd ] || return 0
+
+   echo $user pptp-server $passwd *  $CHAP_SECRETS


This file will grow indefinitely with each system start.


+}
+
+setup_config() {
+   local section=$1
+
+   config_get enabled $section enabled
+   [ $enabled -eq 0 ]  return 1
+
+   cp /etc/pptpd.conf $CONFIG
+
+   config_get localip $section localip
+   config_get remoteip $section remoteip
+   [ -n $localip ]  echo localip  $localip  $CONFIG
+   [ -n $remoteip ]  echo remoteip  $remoteip  $CONFIG
+   return 0
+}
+
+start_pptpd() {
[ -f $DEFAULT ]  . $DEFAULT
mkdir -p $RUN_D
for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; 
do
insmod $m /dev/null 21
done
-   $BIN $OPTIONS
+   $BIN $OPTIONS -c $CONFIG


This should use service wrappers.


+}
+
+start() {
+   config_load pptpd
+   setup_config pptpd || return
+   [ -e $CHAP_SECRETS ]  rm -f $CHAP_SECRETS
+   config_foreach setup_user key
+   start_pptpd
  }

  stop() {
diff --git a/net/pptpd/files/pptpd.uciconf b/net/pptpd/files/pptpd.uciconf
new file mode 100644
index 000..66cf0be
--- /dev/null
+++ b/net/pptpd/files/pptpd.uciconf
@@ -0,0 +1,8 @@
+config service 'pptpd'
+   option 'enabled' '0'
+   option 'localip' '192.168.0.1'
+   option 'remoteip' '192.168.0.20-30'
+
+config 'key'


Wouldn't be a section name like config login better suited?


+   option 'user' 'youruser'
+   option 'passwd' 'yourpass'


For consistency with existing configs it is better to write out the
option names, means username and password instead of user and
passwd.


~ Jow



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 3/6] pptpd: Add uci configuration for PPTPD.

2013-10-15 Thread Jo-Philipp Wich
Hi,

comments inline.

On 11.10.2013 12:30, Bruno Randolf wrote:
 Signed-off-by: Bruno Randolf b...@einfach.org
 ---
  net/pptpd/Makefile|  3 +++
  net/pptpd/files/pptpd.init| 40 ++--
  net/pptpd/files/pptpd.uciconf |  8 
  3 files changed, 49 insertions(+), 2 deletions(-)
  create mode 100644 net/pptpd/files/pptpd.uciconf
 
 diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
 index e79e0a7..0a2f642 100644
 --- a/net/pptpd/Makefile
 +++ b/net/pptpd/Makefile
 @@ -41,6 +41,7 @@ MAKE_FLAGS += \
  define Package/pptpd/conffiles
  /etc/pptpd.conf
  /etc/ppp/options.pptpd
 +/etc/config/pptpd
  endef
  
  define Package/pptpd/install
 @@ -58,6 +59,8 @@ define Package/pptpd/install
   $(INSTALL_BIN) ./files/pptpd.init $(1)/etc/init.d/pptpd
   $(INSTALL_DIR) $(1)/etc/ppp
   $(INSTALL_DATA) ./files/options.pptpd $(1)/etc/ppp/
 + $(INSTALL_DIR) $(1)/etc/config
 + $(INSTALL_DATA) ./files/pptpd.uciconf $(1)/etc/config/pptpd

Per convention, shipped uci configs are called program.config in files/.

  endef
  
  $(eval $(call BuildPackage,pptpd))
 diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
 index a74973c..79c0ab6 100644
 --- a/net/pptpd/files/pptpd.init
 +++ b/net/pptpd/files/pptpd.init
 @@ -6,14 +6,50 @@ BIN=pptpd
  DEFAULT=/etc/default/$BIN
  RUN_D=/var/run
  PID_F=$RUN_D/$BIN.pid
 +CONFIG=/tmp/pptpd.conf

For consistency, native configs autogenerated from uci should go into
the /var/etc directory.

 +CHAP_SECRETS=/etc/ppp/chap-secrets

This should reside in /var/etc or /var/run, if pptp cannot be isntructed
to look for this file there it should be symlinked there.

  
 -start() {
 +setup_user() {
 + local section=$1
 +
 + config_get user $section user
 + config_get passwd $section passwd
 + [ -n $user ] || return 0
 + [ -n $passwd ] || return 0
 +
 + echo $user pptp-server $passwd *  $CHAP_SECRETS

This file will grow indefinitely with each system start.

 +}
 +
 +setup_config() {
 + local section=$1
 +
 + config_get enabled $section enabled
 + [ $enabled -eq 0 ]  return 1
 +
 + cp /etc/pptpd.conf $CONFIG
 +
 + config_get localip $section localip
 + config_get remoteip $section remoteip
 + [ -n $localip ]  echo localip  $localip  $CONFIG
 + [ -n $remoteip ]  echo remoteip  $remoteip  $CONFIG
 + return 0
 +}
 +
 +start_pptpd() {
   [ -f $DEFAULT ]  . $DEFAULT
   mkdir -p $RUN_D
   for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; 
 do
   insmod $m /dev/null 21
   done
 - $BIN $OPTIONS
 + $BIN $OPTIONS -c $CONFIG

This should use service wrappers.

 +}
 +
 +start() {
 + config_load pptpd
 + setup_config pptpd || return
 + [ -e $CHAP_SECRETS ]  rm -f $CHAP_SECRETS
 + config_foreach setup_user key
 + start_pptpd
  }
  
  stop() {
 diff --git a/net/pptpd/files/pptpd.uciconf b/net/pptpd/files/pptpd.uciconf
 new file mode 100644
 index 000..66cf0be
 --- /dev/null
 +++ b/net/pptpd/files/pptpd.uciconf
 @@ -0,0 +1,8 @@
 +config service 'pptpd'
 + option 'enabled' '0'
 + option 'localip' '192.168.0.1'
 + option 'remoteip' '192.168.0.20-30'
 +
 +config 'key'

Wouldn't be a section name like config login better suited?

 + option 'user' 'youruser'
 + option 'passwd' 'yourpass'

For consistency with existing configs it is better to write out the
option names, means username and password instead of user and
passwd.


~ Jow



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/6] pptpd: Add uci configuration for PPTPD.

2013-10-11 Thread Bruno Randolf
Signed-off-by: Bruno Randolf b...@einfach.org
---
 net/pptpd/Makefile|  3 +++
 net/pptpd/files/pptpd.init| 40 ++--
 net/pptpd/files/pptpd.uciconf |  8 
 3 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 net/pptpd/files/pptpd.uciconf

diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
index e79e0a7..0a2f642 100644
--- a/net/pptpd/Makefile
+++ b/net/pptpd/Makefile
@@ -41,6 +41,7 @@ MAKE_FLAGS += \
 define Package/pptpd/conffiles
 /etc/pptpd.conf
 /etc/ppp/options.pptpd
+/etc/config/pptpd
 endef
 
 define Package/pptpd/install
@@ -58,6 +59,8 @@ define Package/pptpd/install
$(INSTALL_BIN) ./files/pptpd.init $(1)/etc/init.d/pptpd
$(INSTALL_DIR) $(1)/etc/ppp
$(INSTALL_DATA) ./files/options.pptpd $(1)/etc/ppp/
+   $(INSTALL_DIR) $(1)/etc/config
+   $(INSTALL_DATA) ./files/pptpd.uciconf $(1)/etc/config/pptpd
 endef
 
 $(eval $(call BuildPackage,pptpd))
diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
index a74973c..79c0ab6 100644
--- a/net/pptpd/files/pptpd.init
+++ b/net/pptpd/files/pptpd.init
@@ -6,14 +6,50 @@ BIN=pptpd
 DEFAULT=/etc/default/$BIN
 RUN_D=/var/run
 PID_F=$RUN_D/$BIN.pid
+CONFIG=/tmp/pptpd.conf
+CHAP_SECRETS=/etc/ppp/chap-secrets
 
-start() {
+setup_user() {
+   local section=$1
+
+   config_get user $section user
+   config_get passwd $section passwd
+   [ -n $user ] || return 0
+   [ -n $passwd ] || return 0
+
+   echo $user pptp-server $passwd *  $CHAP_SECRETS
+}
+
+setup_config() {
+   local section=$1
+
+   config_get enabled $section enabled
+   [ $enabled -eq 0 ]  return 1
+
+   cp /etc/pptpd.conf $CONFIG
+
+   config_get localip $section localip
+   config_get remoteip $section remoteip
+   [ -n $localip ]  echo localip  $localip  $CONFIG
+   [ -n $remoteip ]  echo remoteip  $remoteip  $CONFIG
+   return 0
+}
+
+start_pptpd() {
[ -f $DEFAULT ]  . $DEFAULT
mkdir -p $RUN_D
for m in arc4 sha1 slhc crc-ccitt ppp_generic ppp_async ppp_mppe_mppc; 
do
insmod $m /dev/null 21
done
-   $BIN $OPTIONS
+   $BIN $OPTIONS -c $CONFIG
+}
+
+start() {
+   config_load pptpd
+   setup_config pptpd || return
+   [ -e $CHAP_SECRETS ]  rm -f $CHAP_SECRETS
+   config_foreach setup_user key
+   start_pptpd
 }
 
 stop() {
diff --git a/net/pptpd/files/pptpd.uciconf b/net/pptpd/files/pptpd.uciconf
new file mode 100644
index 000..66cf0be
--- /dev/null
+++ b/net/pptpd/files/pptpd.uciconf
@@ -0,0 +1,8 @@
+config service 'pptpd'
+   option 'enabled' '0'
+   option 'localip' '192.168.0.1'
+   option 'remoteip' '192.168.0.20-30'
+
+config 'key'
+   option 'user' 'youruser'
+   option 'passwd' 'yourpass'
-- 
1.8.1.2
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel