aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/filesystem.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-20cmake,wslua,wsutil: load files from run/ instead of source treePeter Wu1-1/+14
Fixes Lua on macOS, tested with an out-of-tree build: WS_BIN_PATH=$PWD/run ../wireshark/test/test.sh -s wslua Previously programs that were ran from the build directory would load data files (radius/, diameter/, init.lua) from the source directory. Then in the case of Lua, files were loaded from the program directory ($BUILDDIR/run/init.lua on Linux) or source directory (sSOURCEDIR/epan/wslua/console.lua). On macOS, this does not work for Lua since files are installed into $BUILDDIR/run/Wireshark.app/Contents/Resources/share/wireshark/init.lua instead. Since CMake always copies data files (radius, console.lua, etc.) into the build directory, make get_datafile_dir() return this "run" directory instead. Change-Id: If97d2f5686271caf9ad4d4e4fc58e902dc592a98 Reviewed-on: https://code.wireshark.org/review/19330 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-12-09ui: move filesystem code to wsutil/filesystem.cDario Lombardo1-0/+23
This function can be used by code outside ui (eg. extcap). Ping-Bug: 13218 Change-Id: Ic11f7acebefeaf777692df044ebff9b1bc387aa3 Reviewed-on: https://code.wireshark.org/review/19178 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-05Update a comment to reflect current reality.Guy Harris1-11/+15
Change-Id: Ied84e0363161ebc42c8cf24e7ade4b1b4e536448 Reviewed-on: https://code.wireshark.org/review/19074 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-07-23filesystem.c: Don't constify mallocated pointerJoão Valverde1-15/+12
Change-Id: I8991682bda256c5e1c09a303b0243e240b276101 Reviewed-on: https://code.wireshark.org/review/16602 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-22Handle ENAMETOOLONG.Gerald Combs1-0/+8
g_strerror doesn't appear to handle ENAMETOOLONG. Check for it ourselves. Change-Id: Icd113a81e8d95bb3c84c91bb420a1a6a19bf5d40 Reviewed-on: https://code.wireshark.org/review/16041 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-16filesystem: Fix build dir detection when using cmakePeter Wu1-3/+17
Fixes loading of plugins by detecting the build output directory of cmake. This requires a "CMakeCache.txt" file to be present in the parent directory (above run/). Change-Id: I297432cdcd0981646058410f3eadf5f73b5248c8 Reviewed-on: https://code.wireshark.org/review/7453 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-04Include ws_diag_control.h in config.hJoão Valverde1-2/+1
Change-Id: Ia394071710ecda3b0e6686a51fbca45a8ff20317 Reviewed-on: https://code.wireshark.org/review/14749 Petri-Dish: João Valverde <j@v6e.pt> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
2016-04-03wsutil: Remove getenv_utf8(), replaced with g_getenv()João Valverde1-21/+20
Replace getenv() calls in filesystem.c too for consistency. Change-Id: I31425179290e556e6696953531989d93777adf92 Reviewed-on: https://code.wireshark.org/review/14752 Petri-Dish: João Valverde <j@v6e.pt> Reviewed-by: João Valverde <j@v6e.pt> Tested-by: João Valverde <j@v6e.pt> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-11Remove the last remnants of U3 support.Gerald Combs1-66/+21
Change-Id: Ide4c177e67a77c5f9495b3b4c0f817f40e6dde30 Reviewed-on: https://code.wireshark.org/review/14425 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2016-01-07Clean up indentation.Guy Harris1-1/+1
Change-Id: Ica6615ef80867e911a1244a8a54411519033b275 Reviewed-on: https://code.wireshark.org/review/13105 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-07Don't assume a stat() fails only if the target file doesn't exist.Guy Harris1-2/+31
If the error is something other than ENOENT, return that error indication. Change-Id: If866cab5f0de0e4fa8b1ed1cead1290feb88a3cb Reviewed-on: https://code.wireshark.org/review/13091 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-12-14Make init_progfile_dir() take a function pointer [-Wpedantic]João Valverde1-2/+6
Change-Id: I45f8ea5ee6ccc5a484c60ad6e686aaf30f6b0c98 Reviewed-on: https://code.wireshark.org/review/12557 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-07Clean up includes of unistd.h, fcntl.h, and sys/stat.h.Guy Harris1-12/+0
Have wsutil/file_util.h include them on UN*X, just as it includes io.h on Windows, so we can have a rule of "if you do file operations, include <wsutil/file_util.h> and use the routines in it". Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't necessary (whether because of the addition of them to wsutil/file_util.h or because they weren't needed in the first place). Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f Reviewed-on: https://code.wireshark.org/review/11619 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-10-28Just use g_mkdir_with_parents() to make the .config directory on UN*X.Guy Harris1-8/+11
It will create all the relevant directories (if it can), using g_mkdir(), which is a wrapper for mkdir() on UN*X - just as ws_mkdir() is, so we don't need to make our own copy that uses ws_mkdir. Bug: 11645 Change-Id: I68affc6fabccf58dace75af078d9bfd67a1b47b2 Reviewed-on: https://code.wireshark.org/review/11373 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-10-28Do the "create parent of config file directory" stuff on UN*X as well.Guy Harris1-11/+8
~ obviously exists, but ~/.config might not, making it impossible to create ~/.config/wireshark. Bug: 11645 Change-Id: Ia267b168eb7b1438d4c35a6bb89df9d7bfcbd3f3 Reviewed-on: https://code.wireshark.org/review/11368 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-10-19On UN*X, use XDG_CONFIG_HOME/wireshark for configuration files.Guy Harris1-63/+88
If it doesn't exist, but ~/.wireshark does, continue to use that, for backwards compatibility. Derived from change I7fa64d6e8bd43c6a5dec93e30a4f69a747c34256. Bug: 6353 Change-Id: I937f94b19a371486b7ea2228e51994cc4c72b501 Reviewed-on: https://code.wireshark.org/review/11137 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-11terminate readlink resultTobias Stoeckmann1-6/+12
The readlink function does not guarantee to nul-terminate its result string. Therefore, it should be done in wsutil/filesystem.c. Change-Id: Id96533e825a302a1922ce9ac7ee47d5525ac9c39 Reviewed-on: https://code.wireshark.org/review/9597 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-30Use ws_fstat64() to determine the size of an open file.Guy Harris1-19/+0
fseek() to the end, followed by ftell(), is a bit of an odd way to get the file size. Use ws_fstat64() instead. Check that the file is a regular file, while we're at it. This means we don't have to check before opening. Bug: 11268 Change-Id: I31ee20dd5568d10541375cf97b286abfc1384d1c Reviewed-on: https://code.wireshark.org/review/9230 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-24Check _MSC_VER is defined before we use itEvan Huus1-1/+1
Otherwise it breaks a bunch of stuff on Linux machines because of the way gcc's preprocessor works (buildbot decryption tests, extcap, etc). Originally added in Ic5360089f96be620fbe99ba4e819e0caa5ca0215 Change-Id: Iad43fa1415aa331ae375771adac0818ea1b99060 Reviewed-on: https://code.wireshark.org/review/9091 Reviewed-by: Evan Huus <eapache@gmail.com>
2015-06-23[MSVC 2015] file_exists() fails on MSVC2105 as file_stat.st_ino gets resetAndersBroman1-1/+2
to zero in the function call if the file does not exist. The general code seems to work with MSVC2015 so use that. Change-Id: Ic5360089f96be620fbe99ba4e819e0caa5ca0215 Reviewed-on: https://code.wireshark.org/review/9070 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-04-17Make androiddump loadable on OS X.Gerald Combs1-2/+2
Make sure the target location for extcap executables and extcap_dir match on OS X. Set the extcap directory to Contents/MacOS/extcap. The Mac Developer Library documentation doesn't explicitly define "Resources", but examples include data files and not executables. It does state that executables shouldn't go into PlugIns. Make sure we rpathify androiddump. Change-Id: If36c762e2a1991c26e5c01a870deaf191bcf9f94 Reviewed-on: https://code.wireshark.org/review/8093 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-04-07Win32: Restore the versioned plugin installation path.Gerald Combs1-1/+24
Revert parts of g2ef72cb and g7710da4 so that the NSIS installer once again places plugins in $INSTDIR\plugins\$VERSION. This matches the behavior of Autotools and previous Windows installers, and reduces the chances of a version mismatch if the user happens to install a custom plugin. Leave the development plugin path unversioned. Leave the extcap path unversioned for now. Change-Id: I861d4ee12975fba4b642e391871c5e852d92a2fe Reviewed-on: https://code.wireshark.org/review/7976 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Petri-Dish: Graham Bloice <graham.bloice@trihedral.com> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-03-25Add support for WIRESHARK_EXTCAP_DIR environment variable on WindowsPascal Quantin1-1/+11
This can be useful when a user cannot modify the Wireshark installation folder (due to UAC restriction for example) This is already supported on Linux / OSX Change-Id: Icfcb43908de1fd8cd415cd31a98219eab1c757c8 Reviewed-on: https://code.wireshark.org/review/7809 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-24Since g2ef72cb, plugins are no more stored in plugins/$VERSION folderPascal Quantin1-48/+2
Also update the custom samples to reflect the latest changes done Change-Id: I2ac865fad1acdef5a5c4d68a155cbdf970c306f5 Reviewed-on: https://code.wireshark.org/review/7805 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-02-20Just have init_progfile_dir() take a void pointer.Guy Harris1-3/+3
dladdr() takes a void * as a code pointer; have init_progfile_dir() do so, and do the casting in the calls. We don't care about the signature of the function whose address we're passing, we just want to pass a pointer to *something* in the main program. Change-Id: I9372620a97b0eb53c2bb3c0c41a238b4408f3709 Reviewed-on: https://code.wireshark.org/review/7270 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-02-18Fix various warnings in wireshark-qt.cpp.Gerald Combs1-1/+1
Squelch warnings due to (char *) casts. Use "include_directories(SYSTEM..." in CMakeLists.txt so that we don't get pedantic warnings about things we can't easily fix such as QList loop optimizations. Not sure if there's an easy way to do this in Autotools. Pass get_gui_compiled_info to init_progfile_dir. C++ don't have to show you any stinkin' ::main. warning: ISO C++ forbids taking address of function ‘::main’ [-Wpedantic] Change-Id: If1c77284ab0d1b4786bce4e926a4109dd9b1ae34 Reviewed-on: https://code.wireshark.org/review/7207 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-02-14We use GLib's directory-reading routines, so we don't need <dire[cn]t.h>.Guy Harris1-4/+0
Change-Id: Id86e5d6d0ab24adb1bfff0688f33a40f2fdaed8d Reviewed-on: https://code.wireshark.org/review/7108 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17Get rid of unnecessary includes of ctype.h.Guy Harris1-1/+0
Change-Id: Ic23203f13fd6627b664e8ed1438d328c46328b9f Reviewed-on: https://code.wireshark.org/review/4790 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-06Adjust some whitespace to match editor modelines.Bill Meier1-72/+72
Change-Id: Ia22cac3ebd7a454c156f98d967e6fd61f708a2b3 Reviewed-on: https://code.wireshark.org/review/4489 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-08-21Extcap Capture InterfaceRoland Knall1-0/+111
Extcap is a plugin interface, which allows for the usage of external capture interfaces via pipes using a predefined configuration language which results in a graphical gui. This implementation seeks for a generic implementation, which results in a seamless integration with the current system, and does add all external interfaces as simple interfaces. Windows Note: Due to limitations with GTK and Windows, a gspawn-winXX-helper.exe, respective gspawn-winXX-helper-console.exe is needed, which is part of any GTK windows installation. The default installation directory from the build is an extcap subdirectory underneath the run directory. The folder used by extcap may be viewed in the folders tab of the about dialog. The default installation directory for extcap plugins with a pre-build or installer version of wireshark is the extcap subdirectory underneath the main wireshark directory. For more information see: http://youtu.be/Nn84T506SwU bug #9009 Also take a look in doc/extcap_example.py for a Python-example and in extcap.pod for the arguments grammer. Todo: - Integrate with Qt - currently no GUI is generated, but the interfaces are still usable Change-Id: I4f1239b2f1ebd8b2969f73af137915f5be1ce50f Signed-off-by: Mike Ryan <mikeryan+wireshark@lacklustre.net> Signed-off-by: Mike Kershaw <dragorn@kismetwireless.net> Signed-off-by: Roland Knall <rknall@gmail.com> Reviewed-on: https://code.wireshark.org/review/359 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-08-02Make the nameres test suite work out of tree by looking for the global hostsJeff Morriss1-3/+6
file in the build directory (rather than the source directory). Change-Id: I365e573ee84e9a41aa76f4aa9a4a6efaf42fb60e Reviewed-on: https://code.wireshark.org/review/3334 Reviewed-by: Evan Huus <eapache@gmail.com>
2014-06-16More Python-bindings removal.Jeff Morriss1-112/+0
Change-Id: I4d82175781e65c73179f4c8e737a7900cb050bce Reviewed-on: https://code.wireshark.org/review/2283 Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2014-05-30Set PLUGIN_INSTALL_DIR properly for wireshark.pcBalint Reczey1-2/+2
Change-Id: I64c04095ce780ce2cc44a54a68695506d27e5747 Reviewed-on: https://code.wireshark.org/review/1861 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-19The 1.11.x installer puts the global plugins in the wrong place [Mac OS X]Alexis La Goutte1-2/+2
Issue found by rols Fix comment and use the correct plugin_dir path (missing wireshark folder) Change-Id: I298bc5e9872d8c20c5baeaaf056262b9668f15bf Closed-bug: 9854 Reviewed-on: https://code.wireshark.org/review/745 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-19The 1.11.x installer puts the global plugins in the wrong place [Mac OS X]Alexis La Goutte1-1/+1
Issue found by rols The installer puts the normal included plugins (e.g. mate, wimax) in /Applications/Wireshark.app/Contents/Frameworks/wireshark/plugins, however the global plugins directory is set to /Applications/Wireshark.app/Contents/Resources/lib/wireshark/plugins (as it was in previous versions) so no plugins load at startup. In order to make them load you have to create this directory and copy the plugins there, or put them in your personal directory. From remark of Gerald, use recommandation of Bundle Programming Guide (use Contents/PlugIns for plugin) https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW19 Change-Id: Ib1ae7da48a8fa94f7037912cd44c05532a238b71 Closed-bug: 9854 Reviewed-on: https://code.wireshark.org/review/602 Reviewed-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-01-10Make internal functions staticAnders Broman1-1/+1
svn path=/trunk/; revision=54686
2013-11-20Remove a few (now unused) variables.Michael Mann1-2/+0
svn path=/trunk/; revision=53442
2013-11-19Fix missing semicolon.Guy Harris1-1/+1
svn path=/trunk/; revision=53437
2013-11-19Add routines to set the personal file directory paths (personalGuy Harris1-68/+19
configuration file directory and directory in which to save captures), have the routine to parse -P options use them, and move that routine to libui. Have that routine just return a gboolean. svn path=/trunk/; revision=53435
2013-11-18Get rid of unused trivial wrapper routine.Guy Harris1-7/+0
svn path=/trunk/; revision=53403
2013-11-17strncat() bad, g_strlcat() good.Guy Harris1-5/+6
svn path=/trunk/; revision=53381
2013-11-17Clean up indentation.Guy Harris1-2/+2
svn path=/trunk/; revision=53380
2013-11-17Move get_tempfile_path() from filesystem.[ch] to tempfile.[ch].Guy Harris1-9/+0
svn path=/trunk/; revision=53379
2013-11-17Move the epan/filesystem.c routines to wsutil; they're not specific toGuy Harris1-0/+2209
packet dissection, they're specific to the entire Wireshark suite of programs. svn path=/trunk/; revision=53377