Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
b7ceca13
Commit
b7ceca13
authored
Dec 06, 2011
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
netapi32: Simplify the smbpasswd invocation to avoid compiler warnings.
parent
ca8e3c1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
68 deletions
+56
-68
access.c
dlls/netapi32/access.c
+56
-68
No files found.
dlls/netapi32/access.c
View file @
b7ceca13
...
...
@@ -876,39 +876,6 @@ NET_API_STATUS WINAPI NetUserModalsGet(
return
NERR_Success
;
}
static
int
fork_smbpasswd
(
char
*
const
argv
[],
pid_t
*
pid
)
{
#ifdef HAVE_FORK
int
pipe_out
[
2
];
if
(
pipe
(
pipe_out
)
==
-
1
)
return
-
1
;
fcntl
(
pipe_out
[
0
],
F_SETFD
,
FD_CLOEXEC
);
fcntl
(
pipe_out
[
1
],
F_SETFD
,
FD_CLOEXEC
);
switch
((
*
pid
=
fork
()))
{
case
-
1
:
close
(
pipe_out
[
0
]
);
close
(
pipe_out
[
1
]
);
return
-
1
;
case
0
:
dup2
(
pipe_out
[
0
],
0
);
close
(
pipe_out
[
0
]
);
close
(
pipe_out
[
1
]
);
execvp
(
"smbpasswd"
,
argv
);
ERR
(
"can't execute smbpasswd, is it installed?
\n
"
);
_exit
(
1
);
default:
close
(
pipe_out
[
0
]
);
break
;
}
return
pipe_out
[
1
];
#else
ERR
(
"no fork support on this platform
\n
"
);
return
-
1
;
#endif
}
static
char
*
strdup_unixcp
(
const
WCHAR
*
str
)
{
char
*
ret
;
...
...
@@ -921,20 +888,32 @@ static char *strdup_unixcp( const WCHAR *str )
static
NET_API_STATUS
change_password_smb
(
LPCWSTR
domainname
,
LPCWSTR
username
,
LPCWSTR
oldpassword
,
LPCWSTR
newpassword
)
{
#ifdef HAVE_FORK
NET_API_STATUS
ret
=
NERR_Success
;
static
char
option_silent
[]
=
"-s"
;
static
char
option_user
[]
=
"-U"
;
static
char
option_remote
[]
=
"-r"
;
static
char
smbpasswd
[]
=
"smbpasswd"
;
int
pipe_out
;
pid_t
pid
;
char
*
server
=
NULL
,
*
user
,
*
argv
[
7
],
*
old
,
*
new
=
NULL
;
int
pipe_out
[
2
];
pid_t
pid
,
wret
;
int
status
;
char
*
server
=
NULL
,
*
user
,
*
argv
[
7
],
*
old
=
NULL
,
*
new
=
NULL
;
if
(
domainname
&&
!
(
server
=
strdup_unixcp
(
domainname
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
user
=
strdup_unixcp
(
username
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
server
);
return
ERROR_OUTOFMEMORY
;
ret
=
ERROR_OUTOFMEMORY
;
goto
end
;
}
if
(
!
(
old
=
strdup_unixcp
(
oldpassword
)))
{
ret
=
ERROR_OUTOFMEMORY
;
goto
end
;
}
if
(
!
(
new
=
strdup_unixcp
(
newpassword
)))
{
ret
=
ERROR_OUTOFMEMORY
;
goto
end
;
}
argv
[
0
]
=
smbpasswd
;
argv
[
1
]
=
option_silent
;
...
...
@@ -948,48 +927,57 @@ static NET_API_STATUS change_password_smb( LPCWSTR domainname, LPCWSTR username,
}
else
argv
[
4
]
=
NULL
;
pipe_out
=
fork_smbpasswd
(
argv
,
&
pid
);
HeapFree
(
GetProcessHeap
(),
0
,
server
);
HeapFree
(
GetProcessHeap
(),
0
,
user
);
if
(
pipe_out
==
-
1
)
return
NERR_InternalError
;
if
(
!
(
old
=
strdup_unixcp
(
oldpassword
)))
if
(
pipe
(
pipe_out
)
==
-
1
)
{
ret
=
ERROR_OUTOFMEMORY
;
ret
=
NERR_InternalError
;
goto
end
;
}
if
(
!
(
new
=
strdup_unixcp
(
newpassword
)))
fcntl
(
pipe_out
[
0
],
F_SETFD
,
FD_CLOEXEC
);
fcntl
(
pipe_out
[
1
],
F_SETFD
,
FD_CLOEXEC
);
switch
((
pid
=
fork
()))
{
ret
=
ERROR_OUTOFMEMORY
;
case
-
1
:
close
(
pipe_out
[
0
]
);
close
(
pipe_out
[
1
]
);
ret
=
NERR_InternalError
;
goto
end
;
case
0
:
dup2
(
pipe_out
[
0
],
0
);
close
(
pipe_out
[
0
]
);
close
(
pipe_out
[
1
]
);
execvp
(
"smbpasswd"
,
argv
);
ERR
(
"can't execute smbpasswd, is it installed?
\n
"
);
_exit
(
1
);
default:
close
(
pipe_out
[
0
]
);
break
;
}
write
(
pipe_out
,
old
,
strlen
(
old
)
);
write
(
pipe_out
,
"
\n
"
,
1
);
write
(
pipe_out
,
new
,
strlen
(
new
)
);
write
(
pipe_out
,
"
\n
"
,
1
);
write
(
pipe_out
,
new
,
strlen
(
new
)
);
write
(
pipe_out
,
"
\n
"
,
1
);
write
(
pipe_out
[
1
],
old
,
strlen
(
old
)
);
write
(
pipe_out
[
1
],
"
\n
"
,
1
);
write
(
pipe_out
[
1
],
new
,
strlen
(
new
)
);
write
(
pipe_out
[
1
],
"
\n
"
,
1
);
write
(
pipe_out
[
1
],
new
,
strlen
(
new
)
);
write
(
pipe_out
[
1
],
"
\n
"
,
1
);
close
(
pipe_out
[
1
]
);
end:
close
(
pipe_out
);
do
{
wret
=
waitpid
(
pid
,
&
status
,
0
);
}
while
(
wret
<
0
&&
errno
==
EINTR
);
#ifdef HAVE_FORK
{
pid_t
wret
;
int
status
;
do
{
wret
=
waitpid
(
pid
,
&
status
,
0
);
}
while
(
wret
<
0
&&
errno
==
EINTR
);
if
(
ret
==
NERR_Success
&&
(
wret
<
0
||
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)))
ret
=
NERR_InternalError
;
}
#endif
if
(
ret
==
NERR_Success
&&
(
wret
<
0
||
!
WIFEXITED
(
status
)
||
WEXITSTATUS
(
status
)))
ret
=
NERR_InternalError
;
end:
HeapFree
(
GetProcessHeap
(),
0
,
server
);
HeapFree
(
GetProcessHeap
(),
0
,
user
);
HeapFree
(
GetProcessHeap
(),
0
,
old
);
HeapFree
(
GetProcessHeap
(),
0
,
new
);
return
ret
;
#else
ERR
(
"no fork support on this platform
\n
"
);
return
NERR_InternalError
;
#endif
}
/******************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment