MoveFileEx with MOVEFILE_REPLACE_EXISTING flag Fails with LastError = 183 - visual-c++

We have an application that makes a backup of a configuration file by copying it to a sub-folder (see log file entry below) using the following command:-
BOOL b = MoveFileEx(ExistingFileSpec, NewFileSpec, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED);
This appears to work as expected on most systems but on two we get the following warning in our log file:-
11 Jun 2018 10:58:05.437 W. COMMON WARNING MoveFile failed on C:\Program Files\Configuration\Stores.xml to C:\Program Files\Configuration\Backup\Stores.xml LastError=183
Lasterror =183 means "ERROR_ALREADY_EXISTS"
This is odd since MOVEFILE_REPLACE_EXISTING is specifically meant to enable this command to work when the target file exists.
This is happening on Win7 x86 machines.
In a previous version of the code MoveFile was used but with a DeleteFile call immediately prior to ensure the target file did not exist. When the code was rolled back to this version it works.
Any suggestions?

Related

Sybase 16 startserver failed due to missing libsapcrypto.so

We've installed Sybase 16 Express in our Linux box, it was able to startup right after the installation. When we recently try restarting it with the startserver -f RUN_FILE command, it failed to find the libsapcrypto.so file.
~/sap/ASE-16_0/bin> ../sap/ASE-16_0/bin/dataserver: error while loading shared libraries: libsapcrypto.so: cannot open shared object file: No such file or directory
We searched this file, multiple matches presented in the following paths:
./DM/OCS-16_0/lib3p/libsapcrypto.so
./DM/OCS-16_0/lib3p64/libsapcrypto.so
./DM/OCS-16_0/devlib3p64/libsapcrypto.so
./DM/OCS-16_0/devlib3p/libsapcrypto.so
./DM/REP-16_0/lib64/libsapcrypto.so
./DataAccess/ODBC/lib/libsapcrypto.so
./DataAccess64/ODBC/lib/libsapcrypto.so
./OCS-16_0/lib3p/libsapcrypto.so
./OCS-16_0/lib3p64/libsapcrypto.so
./OCS-16_0/devlib3p64/libsapcrypto.so
./OCS-16_0/devlib3p/libsapcrypto.so
Since this hasn't been answered yet, running this command worked for me:
. /opt/sap/SYBASE.sh
Note the different syntax to make sure the environment variables are set in the terminal session, as opposed to using this syntax:
/opt/sap/SYBASE.sh

Robocopy fail to create directories on local hard drive Error 1 Incorrect Function

I'm having an issue with robocopy in which every call to create a new directory on the destination fails. I get outputs such as:
2019/03/19 16:59:11 ERROR 1 (0x00000001) Creating Destination Directory T:\tmp\MIDCAS_SSP\Documents\Customer Reviews\MASPS 1 review\Received Comments\
The copy operation I am attempting is from a sharepoint list mapped to drive X: onto a subdirectory of a physical hard drive T:
OS Name Microsoft Windows 10 Home,
Version 10.0.17134 Build 17134
I have tried several variants, run command as both user and admin. Below is the commands and printout of one of many attempts.
PS T:\tmp\MIDCAS_SSP> .\Sync_XNet.bat
T:\tmp\MIDCAS_SSP>SET Target=T:\tmp\MIDCAS_SSP\Documents
T:\tmp\MIDCAS_SSP>ECHO T:\tmp\MIDCAS_SSP\Documents
T:\tmp\MIDCAS_SSP\Documents
T:\tmp\MIDCAS_SSP>Set XNetSource=X:
T:\tmp\MIDCAS_SSP>net use X: "\\site.name.domain#SSL\DavWWWRoot\sites\MidcasSSP\Shared Documents"
T:\tmp\MIDCAS_SSP>robocopy /XJ /ZB /MIR /FFT /NDL /TS /R:1 /W:2 "X: " "T:\tmp\MIDCAS_SSP\Documents "
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version XP010
-------------------------------------------------------------------------------
Started : Tue Mar 19 16:59:11 2019
Source = X:\
Dest : T:\tmp\MIDCAS_SSP\Documents\
Files : *.*
Options : *.* /FFT /TS /NDL /S /E /COPY:DAT /PURGE /MIR /ZB /XJ /R:1 /W:2
------------------------------------------------------------------------------
2019/03/19 16:59:11 ERROR 1 (0x00000001) Creating Destination Directory T:\tmp\MIDCAS_SSP\Documents\Customer Reviews\MASPS 1 review\Received Comments\
Incorrect function.
Waiting 2 seconds... Retrying...
2019/03/19 16:59:13 ERROR 1 (0x00000001) Creating Destination Directory T:\tmp\MIDCAS_SSP\Documents\Customer Reviews\MASPS 1 review\Received Comments\
Incorrect function.
ERROR: RETRY LIMIT EXCEEDED.
I've checked user and admin rights to the disk.
If I manually create the missing directories, any files therein are copied as intended until a new subdirectory is found but that's a lot of work to get through...
The above listing is using Windows 10 robocopy, but also using the Windows Server 2003 Resource Kit version I have the same problem.
I've also attempted to connect using https:// syntax for the net use command. After I post this I'll reboot as a last ditch attempt.
Ideas where I went wrong? Alternative approaches to back up a remote SharePoint sites' files to off-site disk?
I ran into the same problem, and googling brought me here. Ultimately I didn't find why it doesn't work, but a workaround that did the job for me was to copy the directory structure first using xcopy.
Example:
xcopy /t /e "\\intranet.companyname.com\departments\deptname\Procedures\" "z:\backup\"
robocopy.exe "\\intranet.companyname.com\departments\deptname\Procedures\" "z:\backup" /mir /R:0

Win10: ASDF can't load system (ASDF_OUTPUT_TRANSLATION error)

Update 2
I think #faré is right, it's an output translation problem.
So I declared the evironment variable ASDF_OUTPUT_TRANSLATIONS and set it to E:/. Now (asdf:require-system "my-system") yields a different error: Uneven number of components in source to destination mapping: "E:/" which led me to this SO-topic.
Unfortunately, his solution doesn't work for me. So I tried the other answer and set ASDF_OUTPUT_TRANSLATIONS to (:output-translations (t "E:/")). Now I get yet another error:
Invalid source registry (:OUTPUT-TRANSLATIONS (T "E:/")).
One and only one of
:INHERIT-CONFIGURATION or
:IGNORE-INHERITED-CONFIGURATION
is required.
(will be skipped)
Original Posting
I have a simple system definition but can't get ASDF to load it.
(asdf-version 3.1.5, sbcl 1.3.12 (upgraded to 1.3.18 AMD64), slime 2.19, Windows 10)
What I have tried so far
Following the ASDF manual: "4.1 Configuring ASDF to find your systems"
There it says:
For Windows users, and starting with ASDF 3.1.5, start from your
%LOCALAPPDATA%, which is usually ~/AppData/Local/ (but you can ask in
a CMD.EXE terminal echo %LOCALAPPDATA% to make sure) and underneath
create a subpath config/common-lisp/source-registry.conf.d/
That's exactly what I did:
Echoing %LOCALAPPDATA% which evaluates to C:\Users\my-username\AppData\Local
Underneath I created the subfolders config\common-lisp\source-registry.conf.d\ (In total: C:\Users\my-username\AppData\Local\config\common-lisp\source-registry.conf.d\
The manual continues:
there create a file with any name of your choice but with the type conf, for instance 50-luser-lisp.conf; in this file, add the following line to tell ASDF to recursively scan all the subdirectories under /home/luser/lisp/ for .asd files: (:tree "/home/luser/lisp/")
That’s enough. You may replace /home/luser/lisp/ by wherever you want to install your source code.
In the source-registry.conf.d folder I created the file my.conf and put in it (:tree "C:/Users/my-username/my-systems/"). This folder contains a my-system.asd.
And here comes the weird part:
If I now type (asdf:require-system "my-system") in the REPL I get the following error:
Can't create directory C:\Users\my-username\AppData\Local\common-lisp\sbcl-1.3.12-win-x86\C\Users\my-username\my-systems\C:\
So the problem is not that ASDF doesn't find the file, it does -- but (whatever the reason) it tries to create a really weird subfolder hierarchy which ultimately fails because at the end it tries to create the folder C: but Windows doesn't allow foldernames containing a colon.
Another approach: (push path asdf:*central-registry*)
If I try
> (push #P"C:/Users/my-username/my-systems/" asdf:*central-registry*)
(#P"C:/Users/my-username/my-systems/"
#P"C:/Users/my-username/AppData/Roaming/quicklisp/quicklisp/")
> (asdf:require-system "my-system")
I get the exact same error.
I don't know what to do.
Update
Because of the nature of the weird path ASDF was trying to create I thought maybe I could bypass the problem by specifying a relative path instead of an absolute one.
So I tried
  (:tree "\\Users\\my-username\\my-systems")
in my conf file. Still the same error.
Ahem. It looks like an output-translations problem.
I don't have a Windows machine right now, but this all used to work last time I tried.
Can you setup some ad hoc output-translations for now that will make it work?

Veracode through an error - ASPCONFIG: Could not autodiscover 'components.config'

I have a Veracode plugin in my VS 2013 Professional.
I have ucommerce.dll, Sitecore.Kernel and Sitecore.Analytics.dll
I set copy local true for all above dll files.
When i tried to pre-compile all the web project I'm getting a below error message
1>------ Pre-compile started: Project: XXXXX.Web.PQRPorta\ ------
1>Pre-compiling with command similar to the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -p
"C:/XXXXX.Web.PQRPortal" -v "XXXXX.Web.PQRPortal/" -fixednames -f -c
-d "C:/SVN/trunk/Releases/SourceCode/Source/PrecompiledWeb/XXXXX.Web.PQRPortal"
1>error ASPCONFIG: Could not autodiscover 'components.config'. Make
sure it's present in the application folder
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\' or in a
sub folder. Paths ignored
''C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\bin',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\App_Data',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\obj''
1>XXXXX.Web.PQRPortal\ - 1 error, 0 warnings
Is there any configuration missing?
Update
I found the components.config file inside
C:\inetpub\wwwroot\XXXX\Website\sitecore modules\Shell\uCommerce\Configuration
and I added the file inside the web project root directory and tried to precompile web project, now I’m getting different error error
ASPRUNTIME: Type is not resolved for member 'Castle.Windsor.Configuration.Interpreters.ConfigurationProcessingException,Cast‌​le.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
any solution for it?
The components.config is a file uCommerce need.
The configuration file should be placed somewhere below the uCommerce folder. (not sure where depend on the version) It will automatically be picked up when the application starts up.

java will intermittently not resolve symlinks on Linux

I'm trying to resolve canonical paths for all the files in a folder tree, but for some reason it will not resolve them (and intermittently the JVM security code will resolve the symlink properly within the FilePermission and cause a security error).
Env:
$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
A known symlink in the system is /usr/share/java/gnome-java-bridge.jar:
$ ls -l /usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar
lrwxrwxrwx 1 root root 50 2012-02-24 13:39 /usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar -> ../../../../../../share/java/gnome-java-bridge.jar
The following code should resolve this known symlink:
String symlinkedFilePath =
"/usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar";
File symlinkedFile = new File(symlinkedFilePath);
System.out.println(symlinkedFile.getAbsolutePath());
System.out.println(symlinkedFile.getCanonicalPath());
but produces:
/usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar
/usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar
A further test, using the following code, will sometimes return true for the permission check, but sometimes will return false:
String symlinkedFilePath =
"/usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar";
File symlinkedFile = new File(symlinkedFilePath);
FilePermission recursivePermission = new FilePermission(
symlinkedFile.getParentFile().getParent() + "/-", "read");
FilePermission filePermission = new FilePermission(
symlinkedFile.getAbsolutePath(), "read");
System.out.println(recursivePermission);
System.out.println(filePermission);
System.out.println(
"Can read symlink: " + recursivePermission.implies(filePermission));
The typical result is:
(java.io.FilePermission /usr/lib/jvm/java-6-openjdk/jre/lib/- read)
(java.io.FilePermission /usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar read)
Can read symlink: true
but when debugging, if I step through the creation of the FilePermission on the target file, internally the path is resolved to the symlink, and the output results in:
(java.io.FilePermission /usr/lib/jvm/java-6-openjdk/jre/lib/- read)
(java.io.FilePermission /usr/lib/jvm/java-6-openjdk/jre/lib/ext/gnome-java-bridge.jar read)
Can read symlink: false
The problem is that within the context of the app in which the permission checking actually takes place, the symlink is always resolved by the FilePermission object, but never by my own calls to file.getCanonicalPath() as demonstrated above.
Does this make sense to anyone?
A colleague of mine confirmed the issue on OpenJDK 6u23, but not on any prior or following versions. That being said, since the issue has
A) a work around in the form of the system property
-Dsun.io.useCanonCaches=false
OR
-Dsun.io.useCanonPrefixCache=false
B) appears to be resolved in the later build (u24)
there appears to be little motivation to dig any deeper.
In Unix a symlink is a "special" file, with its own permissions.
The fact that you have read permission on the symbolic link doesn't imply you'll have it for the file linked.
My guess here is that you are running your program as an user that can read the symlink but not the actual file.
When entering debug mode you trigger the call to some method that change the internal state of the FilePermission object making it resolve to the actual file and thus returning you "false".
When you get "true" it's just telling you that you can read the symbolic link.
In your place, I'll check permission on this file:
- /usr/share/java/gnome-java-bridge.jar
and to the two directories:
- /usr/share
- /usr/share/java

Resources