summaryrefslogtreecommitdiff
path: root/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* utils: include utils.h lastFelix Fietkau2022-12-291-1/+2
| | | | | | Fixes conflict with some system headers that use the fallthrough keyword Signed-off-by: Felix Fietkau <nbd@nbd.name>
* utils: fix check_pid_path to work with deleted file as wellKarel Kočí2020-07-111-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | check_pid_patch is checking if process with given PID and executable path is running. If this code fails the rest of the code can be convinced that program is no longer running and possibly spawns new instance that can collide with already running one. This behavior was reproduced with hostapd. Symbolic link exe in process subdirectory in /proc points to original executable. The problem is that it reads as original path plus string ' (deleted)' if file is removed. The process is still running but original file is no longer available on files system. This behavior is triggered not only when file is removed (unlinked) but also when file is replaced. This happens clearly on package update. In general this happens any time all references (hard links) to file are removed from file system. This is not ultimate fix as exe link points to any last reference on file system with preference for original one. The problem is if there are multiple references and the original one is removed. This can be reproduced just by copying executable (hard linking) and unlinking the original one. In such case exe link would point to copy and not to original deleted one. Signed-off-by: Karel Kočí <karel.koci@nic.cz>
* utils: Move IP address validation to parse_addr functionHans Dedecker2016-08-111-18/+1
| | | | | | | | | | | Commit 7a51f23e adds IP address validation in the function parse_ip_and_netmask; however the added check is too restrictive as the function is used on several places resulting into the problem multicast routes cannot be added anymore via UCI. Therefore move the IP host address validation to the function parse_addr so experimantal/multicast addresses cannot be added as a host IP address while multicast routes can be added again. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
* utils.c: Add ip address validationNaresh Kumar Mehta2016-03-071-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | Do not allow configuring invalid IPv4/IPv6 addresses. Curently if I configure LAN IP Address as 224.1.1.1, netifd will configure it. e.g. uci set network.lan.ipaddr='224.1.1.1' uci commit /etc/init.d/network restart Now ifconfig br-lan returns br-lan Link encap:Ethernet HWaddr 00:03:7F:13:BA:17 inet addr:224.1.1.1 Bcast:224.1.1.255 Mask:255.255.255.0 which is wrong. If I use ifconfig eth1 224.1.1.1, I will get ifconfig: SIOCSIFADDR: Invalid argument it means ifconfig is working fine, whereas netifd not. Proposed patch will test IPv4 address to make sure it is class A/B/C only. Similarly IPv6 multicast addresses will not be allowed. Signed-off-by: Naresh Kumar Mehta <naresh@codeaurora.org>
* utils.c: add missing includeFelix Fietkau2015-02-161-0/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* add a helper to convert blobmsg types to luci validate rulesJohn Crispin2014-02-171-0/+19
| | | | Signed-off-by: John Crispin <blogic@openwrt.org>
* utils: add a function for checking if a process given by pid is still aliveFelix Fietkau2013-10-221-0/+27
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Only update resolv.conf if changed (avoid logspam)Steven Barth2013-02-191-0/+28
|
* utils.c: add helper function to format mac addresses as stringsJo-Philipp Wich2012-09-281-0/+11
|
* Move IP address parsing functions to utils.Stéphan Kochen2012-06-181-0/+63
| | | | | | | | | This is a patch series against the netifd repository. This first patch moves some previously static functions to utils, so that the follow up patch may use them from system-linux.c. Signed-off-by: Stéphan Kochen <stephan@kochen.nl>
* vlist is now part of libuboxFelix Fietkau2012-05-261-65/+0
|
* avl_strcmp is now part of libuboxFelix Fietkau2012-05-261-6/+0
|
* flush list in vlist_replace()Felix Fietkau2012-05-201-0/+2
|
* move dns server/search list parsing to interface core to support peerdns=0 + ↵Felix Fietkau2012-05-191-0/+11
| | | | static entries
* add copyright headersFelix Fietkau2012-05-041-0/+13
|
* vlist: add a special node version -1 for nodes that should not be flushed on ↵Felix Fietkau2012-03-041-4/+6
| | | | updates
* simplify vlist, move avl key handling to vlist_add()Felix Fietkau2012-03-041-5/+2
|
* vlist: fix node version update for tree->keep_old/no_deleteFelix Fietkau2012-02-031-1/+3
|
* add a simplified vlist typeFelix Fietkau2012-01-151-0/+40
|
* fix a logic error leading to segfaults on updatesFelix Fietkau2011-10-241-1/+1
|
* utils: fix existing node check when keep_old/no_delete is enabledFelix Fietkau2011-10-031-1/+1
|
* add a new vlist flag for avoiding automatic delete of entriesFelix Fietkau2011-10-021-2/+3
|
* vlist: store a pointer to the real key to make lookups easierFelix Fietkau2011-10-021-2/+2
|
* extend vlist code to allow keeping the old data structure instead of the new ↵Felix Fietkau2011-10-021-0/+5
| | | | one on updates
* make versioned lists more flexible by using an external comparatorFelix Fietkau2011-10-021-13/+7
|
* add code for versioned lists and use it to manage addresses and routesFelix Fietkau2011-09-071-1/+65
|
* move some code to utils.[ch]Felix Fietkau2011-09-071-0/+8